Docker命令-docker ps

docker ps

原文

描述

列出docker容器。

選項

名稱 默認 描述
--all, -a 列出所有容器,默認顯示運行中的容器
--filter, -f 根據(jù)條件過濾顯示內(nèi)容
--format 通過模板展示容器信息
--last, -n -1 顯示最近創(chuàng)建的n個容器(包含所有容器狀態(tài))
--latest, -l 顯示最近創(chuàng)建的容器(包含所有容器狀態(tài))
--no-trunc 不截斷輸出
--quiet, -q '靜默模式',只展示容器ID
--size, -s 顯示容器總的文件大小

使用示例

  1. 一般使用
$ docker ps
$ docker ps -a
  1. filter使用
$ docker ps --filter name=nginx
$ docker ps -a --filter exited=0
$ docker ps --filter status=running
$ docker ps --filter expose=3306
  1. format使用
$ docker ps --format "{{.ID}}: {{.Names}}: {{.Command}}"
a6bb8030cefc: zk2181: "/docker-entrypoint.…"
f3dbb867fe91: mysql: "docker-entrypoint.s…"

更多參數(shù)參考

  • filter使用參數(shù)
Filter Description
id Container’s ID
name Container’s name
label An arbitrary string representing either a key or a key-value pair. Expressed as <key> or <key>=<value>
exited An integer representing the container’s exit code. Only useful with --all.
status One of created, restarting, running, removing, paused, exited, or dead
ancestor Filters containers which share a given image as an ancestor. Expressed as <image-name>[:<tag>],<image id>, or <image@digest>
before or since Filters containers created before or after a given container ID or name
volume Filters running containers which have mounted a given volume or bind mount.
network Filters running containers connected to a given network.
publish or expose Filters containers which publish or expose a given port. Expressed as <port>[/<proto>] or <startport-endport>/[<proto>]
health Filters containers based on their healthcheck status. One of starting, healthy, unhealthy or none.
isolation Windows daemon only. One of default, process, or hyperv.
is-task Filters containers that are a “task” for a service. Boolean option (true or false)
  • format
Placeholder Description
.ID Container ID
.Image Image ID
.Command Quoted command
.CreatedAt Time when the container was created.
.RunningFor Elapsed time since the container was started.
.Ports Exposed ports.
.Status Container status.
.Size Container disk size.
.Names Container names.
.Labels All labels assigned to the container.
.Label Value of a specific label for this container. For example '{{.Label "com.docker.swarm.cpu"}}'
.Mounts Names of the volumes mounted in this container.
.Networks Names of the networks attached to this container.
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容