Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

docker ps with ip

# In order to extract the ip, you can do something like 
docker inspect $CID | grep IPAddress | cut -d '"' -f 4, it works fine :) – 

# Bringing it all together, this shell alias should list all container ids and their ips: 
alias  dockerip='docker ps | tail -n +2 | while read cid b; do echo -n "$cid	"; docker inspect $cid | grep IPAddress | cut -d " -f 4; done' – 

# As mentionned by @user3119830, there is a new option to inspect. Now, you can get the Ip easier with 
docker inspect -format '{{ .NetworkSettings.IPAddress }}' ${CID}

# Just a note. The single dash options are being deprecated so that -format will become --format. – 
docker inspect -format '{{ .NetworkSettings.IPAddress }}' ${CID} is the new syntax. -format is deprecated, it becomes --format. – 
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #docker #ps #ip
ADD COMMENT
Topic
Name
8+5 =