How to find all image tags of a running Docker container?

前端 未结 4 834
没有蜡笔的小新
没有蜡笔的小新 2021-02-19 10:18

I have a bunch of Docker containers running on a server and I used the \"latest\" tag or no tag at all for all of them. Now I want to freeze the image versions, but I have no id

4条回答
  •  离开以前
    2021-02-19 10:47

    The RepoDigest field in the image inspect will have a sha256 reference if you pulled the image from a registry:

    docker ps --format '{{.Image}}' | xargs \
      docker image inspect --format '{{if .RepoDigests}}{{index .RepoDigests 0}}{{end}}'
    

    For a single image like node:latest on your host, that looks like:

    docker image inspect --format '{{index .RepoDigests 0}}' node:latest
    

    That digest cannot be changed by a push to the registry of the same tag name. When you pull the updated tag from the registry, you will see this digest update.

提交回复
热议问题