Get names of all running containers in docker
Find out how to get names and IP addresses of all containers in docker. In Docker each container would have its own name, image name, IP Address etc.
The command that are going to use is
docker ps
This command list all the information like IP Address, Name, Image Name of the docker containers. To run this command you need to log into your docker.
Syntax
docker ps [OPTIONS]
Just run docker ps command to view details of containers.
jenkins@5d54ee66f805:/$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5d54ee66f805 jenkins_image "/sbin/tini -- /usr/…" 4 weeks ago Up 4 weeks 0.0.0.0:8080->8080/tcp, 0.0.0.0:50000->50000/tcp smart-app-jenkins
To view all the containers (including hidden containers) pass -a to docker ps command.
jenkins@5d54ee66f805:/$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b790b3cff76c jenkins_image "/sbin/tini -- /usr/…" 2 days ago Exited (137) 2 days ago great_cray 6364e39943e6 jenkins_image "/sbin/tini -- /usr/…" 2 days ago Created pensive_satoshi 8b34f1b7778a jenkins_image "/sbin/tini -- /usr/…" 2 days ago Exited (137) 2 days ago stupefied_tu 7317172f3abb jenkins_image "/sbin/tini -- /usr/…" 2 days ago Exited (130) 2 days ago infallible_satoshi 5d54ee66f805 jenkins_image "/sbin/tini -- /usr/…" 4 weeks ago Up 4 weeks 0.0.0.0:8080->8080/tcp, 0.0.0.0:50000->50000/tcp smart-app-jenkins
To view the space used by the containers pass -s to docker ps command.
jenkins@5d54ee66f805:/$ docker ps -s CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES SIZE 5d54ee66f805 jenkins_image "/sbin/tini -- /usr/…" 4 weeks ago Up 4 weeks 0.0.0.0:8080->8080/tcp, 0.0.0.0:50000->50000/tcp smart-app-jenkins 45MB (virtual 1.7GB)
You can filter on the containers’ information using –filter flag.
jenkins@5d54ee66f805:/$ docker ps -a --filter "name=great_cray" CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b790b3cff76c jenkins_image "/sbin/tini -- /usr/…" 2 days ago Exited (137) 2 days ago great_cray
In the above command, I filter the containers with name great_cray