225k views
4 votes
How to display the IP address of a running container on the default network?

a) docker inspect --format '{{.NetworkSettings.IPAddress}}'
b) docker container ip
c) docker network inspect --format '{{.Containers..IPAddress}}'
d) docker show ip

User Danopz
by
7.7k points

1 Answer

1 vote

Final answer:

The correct command to display the IP address of a running Docker container on the default network is 'docker inspect --format '{{.NetworkSettings.IPAddress}}' container_name_or_id', where 'container_name_or_id' is the name or ID of the container.

Step-by-step explanation:

To display the IP address of a running container on the default network, you can use the Docker Inspect command along with a specific format option. The correct command from the options provided is:

  • docker inspect --format '{{.NetworkSettings.IPAddress}}'

This command inspects the details of the container and retrieves the IP address from the network settings. It is important to replace container_name_or_id with the actual name or ID of your running container.

User Hohohodown
by
7.6k points