docker ps 命令详解

docker ps 命令:

-a,–all 展现出来所有状态的容器 Show all containers (default shows just running)
-f,–filter 过滤显示 Filter output based on conditions provided
–format 格式化显示 Pretty-print containers using a Go template
-n,–list 简单理解,就是显示输出第n行的docker ps内容 Show n last created containers (includes all states) (default -1)
-l, --latest 相当于ps -n 1 Show the latest created container (includes all states)
–no-trunc 不会截断输出 Don’t truncate output
-q, --quiet 只显示容器的id Only display container IDs
-s, --size 容器文件大小 Display total file sizes

-f 过滤以web开头的容器

docker ps -f name=^web

过滤状态是exit的容器

`docker ps -f status=exited

docker --format 选项

docker ps --format "table {{.ID}}\t{{.Names}}\t{{.Ports}}"

–format可选 功能显示
.ID 容器ID
.Image 镜像ID
.Command 执行的命令
.CreatedAt 容器创建时间
.RunningFor 运行时长
.Ports 暴露的端口
.Status 容器状态
.Names 容器名称
.Label 分配给容器的所有标签
.Mounts 容器挂载的卷
.Networks 容器所用的网络名称
posted @ 2024-07-17 20:23  遇见、  阅读(5)  评论(0编辑  收藏  举报