Use the following commands below to get the container IP address using inspect. We can use the format option with the command to get only a handful of important information. Connecting by the IP address will time out: :/# curl 172.23.0. Inspect command is used to get low level information about all the running docker containers in the host machine. Mind that we can't connect to the “test3” container because it's in a different network. Docker's builtin DNS service will resolve the address for us: :/# curl test2:8080 You may also use grep command to get just the lines matching the string 'IPAddress'. Go towards the end and look into the Networks section to get the container's IP address. Since we're inside the Docker's network, we can also use the alias instead of the IP address. The inspect command gives you many details about the container you are inspecting. Then, use curl to send a request to the “test2” container: :/# curl 172.22.0.2:8080 Communication Between Containersįirst, let's get inside the “test1” container: $ docker exec -it b09a8f47e2a8 /bin/bash First, let's list all containers with their identifiers: $ docker ps -format 'table 'Īlternatively, we can print hosts directly from a container using the docker exec command: $ docker exec 78c10f03ad89 cat /etc/hostsġ72.23.0.3ė8c10f03ad89 5. Similarly, we can inspect a specific container.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |