docker ps

更新时间:
2023-03-30
下载文档

docker ps

查看容器列表。

命令格式

docker ps [option]

参数说明

参数说明是否必填
option查看选项,常用参数如下:
-a:查看所有容器,包括正在运行的和未运行的
-f:根据条件查询容器
–no-trunc:不截断输出
否,若不填 option 则默认显示正在运行的容器

命令示例

  • 示例一:查看正在运行的容器。

    docker ps
    
    CONTAINER ID   IMAGE                                                    COMMAND                  CREATED        STATUS                 PORTS                                                                                                                                                 NAMES
    efa5dec22449   dperson/samba                                            "/sbin/tini -- /usr/…"   3 months ago   Up 4 hours (healthy)   0.0.0.0:139->139/tcp, :::139->139/tcp, 137-138/udp, 0.0.0.0:445->445/tcp, :::445->445/tcp                                                             samba
    1ced6add2af6   registry:latest                                          "/entrypoint.sh /etc…"   3 months ago   Up 4 hours             0.0.0.0:5000->5000/tcp, :::5000->5000/tcp                                                                                                             my_docker_registry
    daee6a38bc4a   nginx:1.21                                               "/docker-entrypoint.…"   4 months ago   Up 4 hours             0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp                                                                              ecsm_frontend
    
  • 示例二:查看正在运行的容器,且不截断输出。

    docker ps --no-trunc
    
    CONTAINER ID                                                       IMAGE                                                    COMMAND                                                                                                                    CREATED        STATUS                 PORTS                                                                                                                                                 NAMES
    efa5dec22449f0008a5f13542002cad9c9df0bb71d58166b1ea5b6023e8d49d2   dperson/samba                                            "/sbin/tini -- /usr/bin/samba.sh -w WORKGROUP -u samba;samba -s Backend;/datas/ecsm/Backend;yes;no;no;samba;samba;samba"   3 months ago   Up 4 hours (healthy)   0.0.0.0:139->139/tcp, :::139->139/tcp, 137-138/udp, 0.0.0.0:445->445/tcp, :::445->445/tcp                                                             samba
    1ced6add2af683e383a0601536603a63a7fcf5dc065875993ad6e350a4a86e07   registry:latest                                          "/entrypoint.sh /etc/docker/registry/config.yml"                                                                           3 months ago   Up 4 hours             0.0.0.0:5000->5000/tcp, :::5000->5000/tcp                                                                                                             my_docker_registry
    daee6a38bc4a1a9e61be0d0938519dc254a571c328f03ab9314ebeb24a4e6d42   nginx:1.21                                               "/docker-entrypoint.sh nginx -g 'daemon off;'"                                                                             4 months ago   Up 4 hours             0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp                                                                              ecsm_frontend
    
  • 示例三:查看所有容器列表,包括正在运行和未运行的容器。

    docker ps -a
    
    CONTAINER ID   IMAGE                                                    COMMAND                  CREATED        STATUS                 PORTS                                                                                                                                                 NAMES
    18ac63c83dc6   harbor.edgeros.com/ecsm/ecsm_backend:20230328-15-36-35   "docker-entrypoint.s…"   22 hours ago   Up 4 hours             0.0.0.0:1114->1114/tcp, :::1114->1114/tcp, 0.0.0.0:1111->1111/udp, :::1111->1111/udp, 0.0.0.0:3000-3001->3000-3001/tcp, :::3000-3001->3000-3001/tcp   ecsm_backend
    efa5dec22449   dperson/samba                                            "/sbin/tini -- /usr/…"   3 months ago   Up 4 hours (healthy)   0.0.0.0:139->139/tcp, :::139->139/tcp, 137-138/udp, 0.0.0.0:445->445/tcp, :::445->445/tcp                                                             samba
    1ced6add2af6   registry:latest                                          "/entrypoint.sh /etc…"   3 months ago   Up 4 hours             0.0.0.0:5000->5000/tcp, :::5000->5000/tcp                                                                                                             my_docker_registry
    daee6a38bc4a   nginx:1.21                                               "/docker-entrypoint.…"   4 months ago   Up 4 hours             0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp                                                                              ecsm_frontend
    
  • 示例四:查看符合条件的容器列表,如使用 --filter status=running 筛选运行中的容器列表。

    docker ps --filter status=running
    
    CONTAINER ID   IMAGE                                                    COMMAND                  CREATED        STATUS                 PORTS                                                                                                                                                 NAMES
    efa5dec22449   dperson/samba                                            "/sbin/tini -- /usr/…"   3 months ago   Up 4 hours (healthy)   0.0.0.0:139->139/tcp, :::139->139/tcp, 137-138/udp, 0.0.0.0:445->445/tcp, :::445->445/tcp                                                             samba
    1ced6add2af6   registry:latest                                          "/entrypoint.sh /etc…"   3 months ago   Up 4 hours             0.0.0.0:5000->5000/tcp, :::5000->5000/tcp                                                                                                             my_docker_registry
    daee6a38bc4a   nginx:1.21                                               "/docker-entrypoint.…"   4 months ago   Up 4 hours             0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp                                                                              ecsm_frontend
    

    查询完容器信息后,可以参考如下命令进行相关操作:

文档内容是否对您有所帮助?
有帮助
没帮助