How Do You Determine the IP Address Assignments of Running Docker Containers?

Problem scenario
You created some Docker containers and assigned them IP addresses. How do you find out what their IP addresses are?

Solution

1. Run this command: docker ps -a # find the container ID of the container you want to know about
2. Run this command but substitute "container_id" with the container ID you found above:
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_id

Leave a comment

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