When having a multiple docker containers docker’ ps
command can be useful to provide an information about all available docker containers residing on the system. By default docker ps
will list all currently running containers on the system:
# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b45f66998a4f ubuntu:14.04 "/bin/bash" 9 minutes agoUp 9 minutes cocky_jang
To list all available running and stopped docker containers append -a
option to the above docker ps
command:
# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 0b7045544535 centos:7 "/bin/bash" 8 minutes ago mycentos b45f66998a4f ubuntu:14.04 "/bin/bash" 12 minutes agoUp 12 minutes cocky_jang
docker ps
command is also able to list a last created docker container by using -l
option:
# docker ps -l CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 0b7045544535 centos:7 "/bin/bash" 9 minutes ago mycentos
Another option to list docker containers is to retrieve a list of all containers created after a specific container using --since
option. For example let’s list all docker containers created after container named cocky_jang
:
# docker ps --since="cocky_jang" CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 0b7045544535 centos:7 "/bin/bash" 13 minutes ago mycentos
Alternatively option --before
will list docker containers created before a specific container. For example the below command will list all containers created before the mycentos
docker container was created:
# docker ps --before="mycentos" CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b45f66998a4f ubuntu:14.04 "/bin/bash" 21 minutes ago Up 21 minutes cocky_jang