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
8.1k 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
8.2k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.