Docker ps Command
docker ps : List containers
Syntax
docker ps [OPTIONS]
OPTIONS description:
-
-a : Show all containers, including those that are not running.
-
-f : Filter the display content based on conditions.
-
--format : Specify a template file for the return value.
-
-l : Show the most recently created container.
-
-n : List the n most recently created containers.
-
--no-trunc : Do not truncate the output.
-
-q : Quiet mode, only display container IDs.
-
-s : Show the total file size.
Examples
List all running container information.
tutorialpro@tutorialpro:~$ docker ps
CONTAINER ID IMAGE COMMAND ... PORTS NAMES
09b93464c2f7 nginx:latest "nginx -g 'daemon off" ... 80/tcp, 443/tcp mytutorialpro
96f7f14e99ab mysql:5.6 "docker-entrypoint.sh" ... 0.0.0.0:3306->3306/tcp mymysql
Output details:
CONTAINER ID: Container ID.
IMAGE: Image used.
COMMAND: Command run when the container started.
CREATED: Time the container was created.
STATUS: Container status.
Statuses include:
- created
- restarting
- running
- removing
- paused
- exited
- dead
PORTS: Port information of the container and the type of connection used (tcp\udp).
NAMES: Automatically assigned container name.
List the 5 most recently created containers.
tutorialpro@tutorialpro:~$ 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 ...
List all created container IDs.
tutorialpro@tutorialpro:~$ docker ps -a -q
09b93464c2f7
b8573233d675
b1a0703e41e7
f46fb1dec520
a63b4a5597de
6a4aa42e947b
de7bb36e7968
43a432b73776
664a8ab1a585
ba52eb632bbd
...