Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

docker ps with ip

#Add this shell script in your ~/.bashrc or relevant file:

nano ~/.bashrc

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

#Then, to get an IP address of a container, simply do this:

docker-ip YOUR_CONTAINER_ID

#For the new version of the Docker, please use the following:

docker-ip() {
   docker inspect --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$@"
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #docker #ps #ip
ADD COMMENT
Topic
Name
6+4 =