user824624
user824624

Reputation: 8056

How to update Docker image when there is new image version?

I am currently running the official ghost Docker image, and use this image to build several containers.

If I want to update the my Docker image, I simply just use the command:

docker pull ghost
docker restart oldcontainer 

Does it work ?

Upvotes: 9

Views: 14680

Answers (2)

VonC
VonC

Reputation: 1323025

A docker restart does a docker stop (or docker kill if the stop times out), which puts a container in an exit status, followed by a docker start, which starts the same container.

The fact that the image might have changed isn't detected at all in that process.

Removing and doing a full docker run with all the right parameter would pick up on an image change. See "How to upgrade docker container after its image changed"

Upvotes: 7

helmbert
helmbert

Reputation: 37934

No. Updating an image will not affect the images that were built from that image, and certainly not affect the already-running containers that were created from this image.

One possible workflow would be sth. like this:

  1. Pull new version of base image
  2. Build new version of your own image on top of the image
  3. Destroy and re-create your own containers from the newly-built image

Upvotes: 7

Related Questions