Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restart option #478

Closed
blackrosezy opened this issue Sep 10, 2014 · 22 comments
Closed

restart option #478

blackrosezy opened this issue Sep 10, 2014 · 22 comments

Comments

@blackrosezy
Copy link

Docker (v 1.2.0) now has an option for restart so containers can auto restart after machine/host reboot:
https://docs.docker.com/reference/commandline/cli/#run

--restart=""  Restart policy to apply when a container exits (no, on-failure[:max-retry], always)

Can we have that option in fig.yml? An e.g:

web:
  image: test/myweb
  restart: always
db:
  image: test/mydb
  restart: always

or more brilliant way, it will restart app stack (web and db):

restart: always
web:
  image: test/myweb
db:
  image: test/mydb

Thanks.

@andrewortman
Copy link

+1

@thaJeztah
Copy link
Member

Regarding the top-level configuration (i.e. Configure the restart-policy for all services), there's another topic that discusses setting global/project-settings here #463

That PR uses project-config for global, project-wide settings. It would be nice to use the same approach here.

paulRbr added a commit to paulRbr/fig that referenced this issue Oct 28, 2014
paulRbr added a commit to paulRbr/fig that referenced this issue Oct 28, 2014
Signed-off-by: Paul Bonaud <paul@bonaud.fr>
paulRbr added a commit to paulRbr/fig that referenced this issue Oct 28, 2014
paulRbr added a commit to paulRbr/fig that referenced this issue Oct 28, 2014
Signed-off-by: Paul Bonaud <paul@bonaud.fr>
paulRbr added a commit to paulRbr/fig that referenced this issue Oct 28, 2014
Signed-off-by: Paul Bonaud <paul@bonaud.fr>
paulRbr added a commit to paulRbr/fig that referenced this issue Oct 28, 2014
Signed-off-by: Paul Bonaud <paul@bonaud.fr>
paulRbr added a commit to paulRbr/fig that referenced this issue Oct 28, 2014
Signed-off-by: Paul Bonaud <paul@bonaud.fr>
paulRbr added a commit to paulRbr/fig that referenced this issue Oct 28, 2014
Signed-off-by: Paul Bonaud <paul@bonaud.fr>
paulRbr added a commit to paulRbr/fig that referenced this issue Oct 28, 2014
Signed-off-by: Paul Bonaud <paul@bonaud.fr>
paulRbr added a commit to paulRbr/fig that referenced this issue Oct 28, 2014
Signed-off-by: Paul Bonaud <paul@bonaud.fr>
paulRbr added a commit to paulRbr/fig that referenced this issue Oct 28, 2014
Signed-off-by: Paul Bonaud <paul@bonaud.fr>
paulRbr added a commit to paulRbr/fig that referenced this issue Oct 28, 2014
Signed-off-by: Paul Bonaud <paul@bonaud.fr>
paulRbr added a commit to paulRbr/fig that referenced this issue Oct 28, 2014
Signed-off-by: Paul Bonaud <paul@bonaud.fr>
paulRbr added a commit to paulRbr/fig that referenced this issue Nov 8, 2014
Signed-off-by: Paul Bonaud <paul@bonaud.fr>
paulRbr added a commit to paulRbr/fig that referenced this issue Nov 8, 2014
Signed-off-by: Paul Bonaud <paul@bonaud.fr>
paulRbr added a commit to paulRbr/fig that referenced this issue Nov 8, 2014
Signed-off-by: Paul Bonaud <paul@bonaud.fr>
@gastonmorixe
Copy link

Please! Can't wait 👍

@docteurklein
Copy link

i'm impatiently waiting for this to land too :)

@drupalmodule
Copy link

+1

@ghost
Copy link

ghost commented Nov 26, 2014

+1 Really interested in this for production use. Is there any way we can help with this feature?

@baptistedonaux
Copy link

+1 @grepped

@gogochan
Copy link

gogochan commented Dec 4, 2014

+1

@cosminonnet
Copy link

+1
What is the best alternative for restarting an exited container launched with Fig? (until this will be supported by Fig v1.0.1+)

@saral
Copy link

saral commented Dec 5, 2014

You can use Upstart like service manager:

description "My Docker Container"
author "Sinan Saral"
start on filesystem and started docker
stop on runlevel [!2345]
respawn
script
  /usr/bin/docker start -a my_container 
end script

kennu added a commit to kennu/fig that referenced this issue Dec 7, 2014
This patch adds the restart_policy parameter to services. The parameter
is passed to the Docker API when starting containers. Its recognized values
are the same as in the Docker CLI ("always" and "on-failure[:max-retry]").

For future compatibility, the policy can also be specified as a
dictionary, which is passed directly to the Docker API (after converting
the keys to CamelCase).

This feature seems to have been requested at least in issue docker#478.

Signed-off-by: Kenneth Falck <kennu@iki.fi>
@bfirsh
Copy link

bfirsh commented Dec 9, 2014

Fixed in #594

@bfirsh bfirsh closed this as completed Dec 9, 2014
@heeren-cliqz
Copy link

I am trying to use restart option to fig as "restart: always ". But getting thrown back the error message "Unsupported config option for web service: 'restart'" . Is it already part of 1.0.1 release or need to added manually as a patch ?

@tomkersten
Copy link

@heeren-cliqz it looks like 1.0.1 was release Nov 5, 2014 and this feature was merged in on December 9...so it's not in the 1.0.1 release as far as I can tell.

@heeren-cliqz
Copy link

@tomkersten Can you suggest me how to use restart feature?
pip install git+https://github.com/docker/fig.git@master#egg=fig-master
I tried to get the latest code but it doesn't seem to work.

@dnephin
Copy link

dnephin commented Jan 7, 2015

What doesn't work?

@heeren-cliqz
Copy link

restart option. Sorry not to be precise. I stop one container by issuing "fig stop container_name". But it didn't start after that.

@dnephin
Copy link

dnephin commented Jan 7, 2015

I haven't used restart policies much myself, but I believe that is the expected behaviour (otherwise you'd never be able to stop the container).

I would try killing the process instead, to see if it restarts.

@heeren-cliqz
Copy link

Well I tried killing the process as well, but container is not restarting back. I think someone didn't test this behavior or there is more required than simply specify in fig file:
restart: always
Any ideas?

@thaJeztah
Copy link
Member

Have you tried creating/starting the container directly with docker and kill it? Is the behavior the same?

IIRC, restart:always should automatically restart the container when the docker daemon is restarted. So you could create two containers, on with and one without restart:always, then stop and start the daemon. Only the container with restart:always should be running after that.

@heeren-cliqz
Copy link

Thanks @thaJeztah. After inspecting my docker containers, indeed the restart policies are changed as per specified criteria.
"RestartPolicy": {
"MaximumRetryCount": 0,
"Name": "always"
},
I think it is more or less the problem with boot2docker as it is not persistent by default and hence when restarted, state of containers are not consistent. Correct me if I am wrong.

@thaJeztah
Copy link
Member

I don't use Boot2docker, but that could of course be a factor. Still keep in mind that fig stop container_name should just stop the container (because you told it to stop), but restarting the docker daemon, or if the process inside the container bails out, docker should try to start it again if a restart:always policy is set. (and keep trying to start it again, every 100ms, 200ms, 400ms and so on)

A nice blog about the restart-policies can be found here; http://www.tech-d.net/2014/09/30/docker-restart-policies/

^^ @SvenDowideit (if you have time); Can you tell if boot2docker persistence makes a difference here?

I also noted that the incrementing interval is not mentioned in the restart policies docs. I think that should be added somewhere, perhaps that whole section should be moved to the Docker run reference so that it can be explained more in depth?

I'm happy to create a PR for that if you think it's a good idea.

yuval-k pushed a commit to yuval-k/compose that referenced this issue Apr 10, 2015
Signed-off-by: Paul Bonaud <paul@bonaud.fr>

Signed-off-by: Yuval Kohavi <yuval.kohavi@gmail.com>
@praveennous
Copy link

Hello All,

Could some one give me steps how to set existing container to restart=always to autostart.Please find my image id and guide me on this.

Image ID :e0418b2f81b4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests