Using the docker inspect command we are able to get the IP address of a Docker container from the host. The docker inspect command allows you to retrieve detailed information about a container, including its IP address.
The below example can helps you how you can use the docker inspect command to get the IP address of a container:
Use your <container_name> with the name or container ID
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <container_name>
Assume that the I would like to find the docker container name is thelinuxfaq_container
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' thelinuxfaq_container
Old Docker client syntax is:
docker inspect --format '{{ .NetworkSettings.IPAddress }}' thelinuxfaq_container
These commands will return the Docker container's IP address.
Note: if the docker container is running on Windows, use double quotes " instead of single quotes ' around the curly braces.
Comments (0)