Docker Community Forums

Share and learn in the Docker community.

Alternative to --restart=no to docker daemon

(Daltonmatos) #1


I need docker to restart my containers in the event they exit with an error, so I use “–restart=on-failure” when creating them. I also need to make sure the containers are up to date with the images built on my CI server before starting them at boot - for that I start the docker daemon with “–restart=false” so I can recreate any containers from updated images and then let the deploy process start the containers.

Now that the --restart argument to the daemon is deprecated, how else I can have my containers restart on failure but not start automatically on boot? I’m using docker 1.7.1, btw.

Thank you.

(Sabin Basyal) #2

I don’t know where this information comes from. Can you locate me where you read deprecating the --restart argument?


(Daltonmatos) #3

Hello @sbasyal,

Here is the latest versoin of the docker daemon code[1], in the file daemon/config.go we can see this message:

“–restart on the daemon has been deprecated in favor of --restart policies on docker run”

Also when I sart docker daemon with this option, it prints this to the console:

~# docker -d --restart=false Warning: '--restart' is deprecated, it will be removed soon. See usage.
Is there another way to have the same behavior of --restart or return this options as official?



(Sabin Basyal) #4

hi @daltonmatos,

Sorry for the confusion. I was wondering if you were talking about deprecating --restart argument with docker run command.
You’re right --restart is deprecated on the daemon because there are multiple restart policies that are per container. So instead of asking daemon to follow a single policy for all containers, you can use --restart argument with each run command for each container with different policies.
Please see


(Daltonmatos) #5

You are not seeing the difference, @sbasyal. --restart=false on the deamon and the restart policies have different behaviors.

If you use any of the restart policies, “on-failure” or “always”, this means that whenever a container crashes, docker daemon will restart this crashed container. But it also means (and here is where my problem begins) when you start docker daemon it will automatically start any existing container.

But if you add the --restart=false to the deamon, it won’t autostart any container. the behavior that I’m trying to maintain, and that is currently gone with this deprecation is:

  • Restart any crashed container
  • Do not autostart any container when docker daemon boots.

See the difference?