How to determine the iP address of a Docker Container

Determining the IP address of a docker container is important when you are learning about docker networking. There are many ways to determine IP address of docker container

You can determine it from the host by using docker inspect command and the container name or id. To get the container name or ID of your container:

$ docker ps

Then use the docker name or ID to run:

$ docker inspect <container_name_or_ID>

You can see it near the bottom part where it specifies the IP Address.

One more easy method is by using this command:

docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <container_name_or_id>

The result it will give is only the IP Address of the docker container.

Leave a Comment

Your email address will not be published. Required fields are marked *