Home > Operation and Maintenance > Docker > What command does docker use to view running containers?

What command does docker use to view running containers?

WBOY
Release: 2022-02-08 16:21:48
Original
41244 people have browsed it

In docker, you can use the ps command to view running containers. The purpose of this command is to list the containers. When the parameter is set to "-a", all containers including those that are not running can be displayed. The syntax is "docker ps -a".

What command does docker use to view running containers?

The operating environment of this tutorial: linux7.3 system, docker-1.13.1 version, Dell G3 computer.

What command docker uses to view running containers

docker ps: List containers

Syntax

docker ps [OPTIONS]
Copy after login

OPTIONS Description:

-a: Display all containers, including those that are not running.

-f: Filter the displayed content based on conditions.

--format: Specify the template file for the return value.

-l: Display recently created containers.

-n: List the recently created n containers.

--no-trunc: Do not truncate output.

-q: Silent mode, only the container number is displayed.

-s: Display the total file size.

Instance

Lists all running container information.

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
Copy after login

Output details:

CONTAINER ID: Container ID.

IMAGE: The image used.

COMMAND: The command to run when starting the container.

CREATED: The creation time of the container.

STATUS: Container status.

There are 7 states:

created (created)

restarting (restarting)

running (running)

removing (migrating)

paused (paused)

exited (stopped)

dead (dead)

PORTS: Container port information and used Connection type (tcp\udp).

NAMES: Automatically assigned container names.

List the information of the 5 recently created containers.

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   ...
Copy after login

Recommended learning: "docker video tutorial"

The above is the detailed content of What command does docker use to view running containers?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template