我正在尝试使用 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)