Skip to content

restart option #478

Closed
Closed

Description

@blackrosezy

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.

Activity

  1. andrewortman commented on Sep 18, 2014

    @andrewortman

    +1

  2. thaJeztah commented on Sep 18, 2014

    @thaJeztah
    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.

  3. 15 remaining items

  4. heeren-cliqz commented on Dec 28, 2014

    @heeren-cliqz

    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 ?

  5. tomkersten commented on Jan 7, 2015

    @tomkersten

    @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.

  6. heeren-cliqz commented on Jan 7, 2015

    @heeren-cliqz

    @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.

  7. dnephin commented on Jan 7, 2015

    @dnephin

    What doesn't work?

  8. heeren-cliqz commented on Jan 7, 2015

    @heeren-cliqz

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

  9. dnephin commented on Jan 7, 2015

    @dnephin

    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.

  10. heeren-cliqz commented on Jan 7, 2015

    @heeren-cliqz

    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?

  11. thaJeztah commented on Jan 7, 2015

    @thaJeztah
    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.

  12. heeren-cliqz commented on Jan 8, 2015

    @heeren-cliqz

    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.

  13. thaJeztah commented on Jan 8, 2015

    @thaJeztah
    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.

  14. praveennous commented on Aug 11, 2015

    @praveennous

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions