9

I was wondering what is happening exactly when I run the same image (already pull locally) multiple time ?

Does it run the dockerfile each time ? (meaning each command in the docker file)

Does it rerun (restart) the container concerned ?

mfrachet
  • 8,772
  • 17
  • 55
  • 110

1 Answers1

10

Does it run the dockerfile each time ?

No: a docker run will create a container based on the image.
The Dockerfile was used to build the image, but it not involved at runtime.

Does it rerun (restart) the container concerned?

It create a new container for each docker run.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • What if a process inside the container writes some files? Does the change affects only the current *container* or the edit is applied to the *image*? – collimarco Apr 10 '20 at 14:12
  • 1
    @collimarco Only the writable container layer, not the layers from the image: see https://stackoverflow.com/a/47947168/6309 – VonC Apr 10 '20 at 14:47