Latest web development tutorials

Docker ps command

Docker command Daquan Docker command Daquan


docker ps: Lists container

grammar

docker ps [OPTIONS]

OPTIONS Description:

  • -a: Displays all containers, including not running.

  • -f: filter content displayed according to the conditions.

  • --format: specifies the return value of the template file.

  • -l: display container recently created.

  • -n: Lists n containers recently created.

  • --no-trunc: not truncate the output.

  • -q: Quiet mode, only the container number.

  • -s: Displays the total file size.

Examples

List all information on a running container.

w3big@w3big:~$ docker ps
CONTAINER ID   IMAGE          COMMAND                ...  PORTS                    NAMES
09b93464c2f7   nginx:latest   "nginx -g 'daemon off" ...  80/tcp, 443/tcp          myw3big
96f7f14e99ab   mysql:5.6      "docker-entrypoint.sh" ...  0.0.0.0:3306->3306/tcp   mymysql

It lists the five most recently created container information.

w3big@w3big:~$ 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 container ID created.

w3big@w3big:~$ docker ps -a -q
09b93464c2f7
b8573233d675
b1a0703e41e7
f46fb1dec520
a63b4a5597de
6a4aa42e947b
de7bb36e7968
43a432b73776
664a8ab1a585
ba52eb632bbd
...

Docker command Daquan Docker command Daquan