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
Docker images and containers are identified by an ID and for a running container you can get the Id of its image and then pull the image corresponding to the given ID.
First you need to use docker inspect
on all your running containers in order to get the sha256
Id the image on which the container is based.
docker inspect
returns the image ID under "Image"
:
{
"Id": "6de053a2afa4499471c5e5c2afe0b0d83c9c7e50fc7e687fb63a7ebfd2bff320",
...
},
"Image": "sha256:26eb6780e26887a6838684a549562c0404fd85c55f71e0af6c79a4da5505d2a7",
....
}
Then you simply have to pull those images by digest (immutable identifier)
$ docker pull node@sha256:the-image-digest-here
or
$ docker pull node@sha256:26eb6780e26887a6838684a549562c0404fd85c55f71e0af6c79a4da5505d2a7
If you are lucky images corresponding to those digests are still available into the docker hub.
After that, is you are still facing latest
images I will suggest you to rename those images with a proper name and tag and pull them in your own docker hub repository to be able to use them directly...