I see that Docker has added something called restarting policies to handle restart of containers in case of, for instance, reboot.
While this is very useful, I see that the restart policy command just work with docker run
and not docker start
. So my question is:
Is there any way to add restarting policies to a container that was already created in the past?
There're two approaches to modify RestartPolicy:
docker commit
your container as a new image, stop & rm the current container, and start a new container with the image.No. And more generally, you can't edit a container once it is created (exposed port, hostname, network settings) via Docker. You would need to recreate it with
docker run
.It is usually good practice to have your container stateless, so it should not cause any issue. Take a look at volumes (
-v
) to help you achieve this.In recent versions of docker (as of 1.11) you have an
update
command: