docker ps-显示图像ID而不是名称

时间:2019-01-07 13:35:53

标签: docker docker-compose container-image

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

3 个答案:

答案 0 :(得分:4)

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

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

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/

答案 1 :(得分:1)

我发现 docker inspect <container-id> 可用于此目的。 它显示包含完整哈希值的 image 字段。

答案 2 :(得分:0)

docker images

将显示图像名称及其ID

相关问题