- 起因:当我想用awk去获取docker正在运行的Container ID,但是还需要学习一下awk的使用
- 过程:学习了一下docker的文档,发现文档中写道docker 自带了format功能
- 结论:通过format去获取ContainerID更加方便快捷
- 使用方法
sudo docker ps
sudo docker ps --format "{{.ID}}"
返回Container ID:47c91ef388bf
-
Format output 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. .State
Container status (for example; "created", "running", "exited"). .Status
Container status with details about duration and health-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.
Docker PS中的使用
最新推荐文章于 2024-09-15 01:05:24 发布