9

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 ?

user824624
  • 7,077
  • 27
  • 106
  • 183

2 Answers2

7

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
helmbert
  • 35,797
  • 13
  • 82
  • 95
  • 1
    so it means if I have the new image, then even restarting the containers based on the old image won't work. – user824624 May 04 '15 at 20:42
  • 1
    Correct. Ideally, you would re-create the container from the (possibly updated) image. That's exactly the reason why it's discouraged to store application data inside a Docker container, btw. (see the answer linked in VonC's answer on that topic). – helmbert May 04 '15 at 20:48
7

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"

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250