docker ps : List containers OPTIONS description: -a : Displays all containers, including those that are not running. -f : Filter the displayed content based on the criteria. –format : Specifies the template file for the return value. -l : Displays the most recently created container. -n : List the most recently created n containers. –no-trunc : The output is not truncated. -q : Silent mode, showing only the container number. -s : Displays the total file size. Lists all running container information. Description of output details: CONTAINER ID: Container ID. IMAGE: The mirror image used. COMMAND: The command that runs when the container is started. CREATED: The time when the container was created. STATUS: Container status. There are 7 states: Created (created) Restarting (restarting) Running (running) Removing (migrating) Paused (pause) Exited (stop) Dead (death) PORTS: The port information of the container and the connection type used (tcpudp). NAMES: The container name that is automatically assigned. Lists the information of the 5 recently created containers. Lists all created container ID. 2.37.1. Grammar ¶
docker ps [OPTIONS]
2.37.2. Example ¶
runoob@runoob:~$ docker ps
CONTAINER ID IMAGE COMMAND ... PORTS NAMES
09b93464c2f7 nginx:latest "nginx -g 'daemon off" ... 80/tcp, 443/tcp myrunoob
96f7f14e99ab mysql:5.6 "docker-entrypoint.sh" ... 0.0.0.0:3306->3306/tcp mymysql
runoob@runoob:~$ docker ps -n 5
CONTAINER ID IMAGE COMMAND CREATED
09b93464c2f7 nginx:latest "nginx -g 'daemon off" 2 days ago ...
b8573233d675 nginx:latest "/bin/bash" 2 days ago ...
b1a0703e41e7 nginx:latest "nginx -g 'daemon off" 2 days ago ...
f46fb1dec520 5c6e1090e771 "/bin/sh -c 'set -x \t" 2 days ago ...
a63b4a5597de 860c279d2fec "bash" 2 days ago ...
runoob@runoob:~$ docker ps -a -q
09b93464c2f7
b8573233d675
b1a0703e41e7
f46fb1dec520
a63b4a5597de
6a4aa42e947b
de7bb36e7968
43a432b73776
664a8ab1a585
ba52eb632bbd
...