Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

get or filter or ouput docker ps custom columns

To get all container names and their IP addresses in just one single command.

docker inspect -f '{{.Name}} - {{.NetworkSettings.IPAddress }}' $(docker ps -aq)
If you are using docker-compose the command will be this:

docker inspect -f '{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)
The output will be:

/containerA - 172.17.0.4
/containerB - 172.17.0.3
/containerC - 172.17.0.2

another example:
docker ps | grep sida | tr -s ' ' | awk '{print $NF}' | xargs docker inspect $1 -f "{{.Name}} - {{json .NetworkSettings.Networks }}" | grep -i networkID
 
 The output will be:
 /docker-compose-sida_web_1 => {"docker-traefik_default":{"IPAMConfig":null,"Links":null,"Aliases":["web","de2326288433"],"NetworkID":"ebc5e603ab6b43c1b0f1853bb182ab6eb39ed86df0131d9fd0d2126cc7aaae82","EndpointID":"00e5c590339cc415eb6505e57ed0a5f009ee6d0ff323987e2c25bfd2d4f26a2c","Gateway":"172.21.0.1","IPAddress":"172.21.0.7","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"MacAddress":"02:42:ac:15:00:07","DriverOpts":null}}
Comment

PREVIOUS NEXT
Code Example
Shell :: auto update environmental variables windows 
Shell :: linx command to enable web security in ubuntu 
Shell :: git expo init 
Shell :: change directory name lunix 
Shell :: adonisjs 5 create model migration controller 
Shell :: What software can I Install after a fresh Ubuntu Setup 
Shell :: linux replace after char 
Shell :: containing globalprotect, pre-dependency problem: globalprotect pre-depends on libqt5webkit5 libqt5webkit5 is not installed. 
Shell :: install OMV core packages on Debian 
Shell :: install curecoin-qt on mint 19 
Shell :: powershell scope currentuser 
Shell :: how to clone git all repository git ubuntu 
Shell :: brew help 
Shell :: LetsEncrypt use alias for acme-challenge directory 
Shell :: visual basic code syntax 
Shell :: wp plugin install through code 
Shell :: github clone mirror 
Shell :: shell command operator and seperator control characters 
Shell :: onefetch install 
Shell :: forward parameters batch script 
Shell :: linux function return 
Shell :: Drupal import db ftom backup 
Shell :: ./bootstrap command not found in dockerfile 
Shell :: turn on indexing win 11 
Shell :: rem command 
Shell :: visual studio copy nuget packages to another project command line 
Shell :: sbt run on save 
Shell :: command to install and initialize React Helmet 
Shell :: environment variables not showing in process.env in create react app in js 
Shell :: flutter update packages command 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =