docker ps-显示图像ID而不是名称 [英] docker ps - show image ID instead of name

查看:951
本文介绍了docker ps-显示图像ID而不是名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用
docker ps 命令显示正在运行的容器。 IMAGE 列显示了创建每个容器的图像的 name 。但是与此同时(在容器运行时)我重建了一些映像。新图像的名称相同,但 ID 不同。现在,我要检查从哪个图像特定容器运行。我不能仅使用图像名称来推断此信息。我需要图像 ID 。是否有可能显示用于运行特定容器的图像的ID?

I display running containers using docker ps command. There is an IMAGE column that shows name of the image that each container was created from. However in the meantime (while containers were running) I have rebuilt some images. The new images have the same names but different IDs. Now I'd like to check from which image specific container was run. I cannot deduce this information using only image name. I need image ID. Is there any possibility to display ID of the image that was used to run specific container?

推荐答案

您可以传递多个容器ID到docker inspect命令,然后使用--format仅获取所需的值。

You can pass multiple container-ids to the docker inspect command and then use the --format to only get the values that you want.

docker inspect --format='{{.Id}} {{.Name}} {{.Image}}' $(docker ps -aq)

这将为您提供所有容器使用的Docker容器ID,名称和图像ID的列表。

This will give you a list of the docker container Ids, names and image IDs that are being used for all of your containers.

asdf1234 /mydockercontainer sha256:abcd1234

https://docs.docker.com/engine/reference/commandline/inspect/

这篇关于docker ps-显示图像ID而不是名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆