Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

docker ps with ip

#Based on some of the answers I loved, I decided to merge them to a function to get all the IP addresses and another for an specific container. They are now in my .bashrc file.

docker-ips() {
    docker inspect --format='{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)
}

docker-ip() {
  docker inspect --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$@"
}

#The first command gives the IP address of all the containers and the second a specific container's IP address.

docker-ips
docker-ip YOUR_CONTAINER_ID
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #docker #ps #ip
ADD COMMENT
Topic
Name
1+7 =