小编Joh*_*ker的帖子

Docker --格式为 json。多个占位符的特定占位符语法

我正在尝试使用 docker ps 和 json format 命令生成如下所示的输出

{"Names":"name"}

docker ps --format '{{json .Names}}'
Run Code Online (Sandbox Code Playgroud)

输出{"name"}没有标签。

docker ps --format '{{json .}}'提供带有标签的所有容器信息,但我不想要所有内容。

最好基于下面的所有占位符名称,我希望得到如下所示的输出,其中包含按我选择的顺序选择的字段:

{"ID":"Container ID", "Image":"Image ID", "Names":"name"}
Run Code Online (Sandbox Code Playgroud)
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 …
Run Code Online (Sandbox Code Playgroud)

json ps docker

6
推荐指数
1
解决办法
7835
查看次数

标签 统计

docker ×1

json ×1

ps ×1