If I create a container using a tag/label
docker run --name some_container -d me/my_image
Update the image with
docker pull me/my_image
And restart the container with
docker restart some_container
Which version does the new container use?
In docker inspect
.Image
gives the id of the specific image, .Config.Image
gives the label.
It uses the image the container was created from. This is pretty easy to verify.
Lets take a look at the image ID for an outdated image:
Cool, now lets create a container based off that image:
We can see the image that container is based off of:
Now we pull an updated
alpine:3.2
:See that it has a new image ID:
But the container is still using the older image ID:
When you check out the images you can see the new one and the old dangling one:
If you tried to delete the old image you will be met with an error:
The image can be deleted once the container that is based off it is removed.
[EDIT] I was wrong. The container will use the previous image even we restart it.
We need to delete and re-create the container from the same tag to use the new revision of the image.