host_integration.rst 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. :title: Host Integration
  2. :description: How to generate scripts for upstart, systemd, etc.
  3. :keywords: systemd, upstart, supervisor, docker, documentation, host integration
  4. Host Integration
  5. ================
  6. You can use your Docker containers with process managers like ``upstart``,
  7. ``systemd`` and ``supervisor``.
  8. Introduction
  9. ------------
  10. If you want a process manager to manage your containers you will need to run
  11. the docker daemon with the ``-r=false`` so that docker will not automatically
  12. restart your containers when the host is restarted.
  13. When you have finished setting up your image and are happy with your
  14. running container, you may want to use a process manager to manage
  15. it. When your run ``docker start -a`` docker will automatically attach
  16. to the process and forward all signals so that the process manager can
  17. detect when a container stops and correctly restart it.
  18. Here are a few sample scripts for systemd and upstart to integrate with docker.
  19. Sample Upstart Script
  20. ---------------------
  21. .. code-block:: bash
  22. description "Redis container"
  23. author "Me"
  24. start on filesystem and started lxc-net and started docker
  25. stop on runlevel [!2345]
  26. respawn
  27. exec docker start -a 0a7e070b698b
  28. Sample systemd Script
  29. ---------------------
  30. .. code-block:: bash
  31. [Unit]
  32. Description=Redis container
  33. Author=Me
  34. After=docker.service
  35. [Service]
  36. Restart=always
  37. ExecStart=/usr/bin/docker start -a 0a7e070b698b
  38. ExecStop=/usr/bin/docker stop -t 2 0a7e070b698b
  39. [Install]
  40. WantedBy=local.target