|
...
|
...
|
@@ -2,67 +2,124 @@
|
|
2
|
2
|
:description: How to generate scripts for upstart, systemd, etc.
|
|
3
|
3
|
:keywords: systemd, upstart, supervisor, docker, documentation, host integration
|
|
4
|
4
|
|
|
|
5
|
+
|
|
|
6
|
+
|
|
|
7
|
+Host Integration
|
|
|
8
|
+================
|
|
|
9
|
+
|
|
|
10
|
+You can use your Docker containers with process managers like ``upstart``,
|
|
|
11
|
+``systemd`` and ``supervisor``.
|
|
|
12
|
+
|
|
5
|
13
|
Introduction
|
|
6
|
|
-============
|
|
|
14
|
+------------
|
|
|
15
|
+
|
|
|
16
|
+When you have finished setting up your image and are happy with your
|
|
|
17
|
+running container, you may want to use a process manager to manage
|
|
|
18
|
+it. To help with this, we provide a simple image: ``creack/manger:min``
|
|
|
19
|
+
|
|
|
20
|
+This image takes the container ID as parameter. We also can specify
|
|
|
21
|
+the kind of process manager and metadata like *Author* and
|
|
|
22
|
+*Description*. The output will will be text suitable for a
|
|
|
23
|
+configuration file, echoed to stdout. It is up to you to create the
|
|
|
24
|
+.conf file (for `upstart
|
|
|
25
|
+<http://upstart.ubuntu.com/cookbook/#job-configuration-file>`_) or
|
|
|
26
|
+.service file (for `systemd
|
|
|
27
|
+<http://0pointer.de/public/systemd-man/systemd.service.html>`_) and
|
|
|
28
|
+put it in the right place for your system.
|
|
|
29
|
+
|
|
|
30
|
+Usage
|
|
|
31
|
+-----
|
|
7
|
32
|
|
|
8
|
|
-When you have finished setting up your image and are happy with your running
|
|
9
|
|
-container, you may want to use a process manager like `upstart` or `systemd`.
|
|
|
33
|
+.. code-block:: bash
|
|
10
|
34
|
|
|
11
|
|
-In order to do so, we provide a simple image: creack/manger:min.
|
|
|
35
|
+ docker run creack/manager:min [OPTIONS] <container id>
|
|
12
|
36
|
|
|
13
|
|
-This image takes the container ID as parameter. We also can specify the kind of
|
|
14
|
|
-process manager and meta datas like Author and Description.
|
|
|
37
|
+.. program:: docker run creack/manager:min
|
|
15
|
38
|
|
|
16
|
|
-If no process manager is specified, then `upstart` is assumed.
|
|
|
39
|
+.. cmdoption:: -a="<none>"
|
|
17
|
40
|
|
|
18
|
|
-Note: The result will be an output to stdout.
|
|
|
41
|
+ Author of the image
|
|
|
42
|
+
|
|
|
43
|
+.. cmdoption:: -d="<none>"
|
|
|
44
|
+
|
|
|
45
|
+ Description of the image
|
|
|
46
|
+
|
|
|
47
|
+.. cmdoption:: -t="upstart"
|
|
|
48
|
+
|
|
|
49
|
+ Type of manager requested: ``upstart`` or ``systemd``
|
|
|
50
|
+
|
|
|
51
|
+Example Output
|
|
|
52
|
+..............
|
|
|
53
|
+
|
|
|
54
|
+.. code-block:: bash
|
|
|
55
|
+
|
|
|
56
|
+ docker run creack/manager:min -t="systemd" b28605f2f9a4
|
|
|
57
|
+ [Unit]
|
|
|
58
|
+ Description=<none>
|
|
|
59
|
+ Author=<none>
|
|
|
60
|
+ After=docker.service
|
|
|
61
|
+
|
|
|
62
|
+ [Service]
|
|
|
63
|
+ Restart=always
|
|
|
64
|
+ ExecStart=/usr/bin/docker start -a b28605f2f9a4
|
|
|
65
|
+ ExecStop=/usr/bin/docker stop -t 2 b28605f2f9a4
|
|
|
66
|
+
|
|
|
67
|
+ [Install]
|
|
|
68
|
+ WantedBy=local.target
|
|
19
|
69
|
|
|
20
|
|
-Usage
|
|
21
|
|
-=====
|
|
22
|
|
-Usage: docker run creack/manager:min [OPTIONS] <container id>
|
|
23
|
70
|
|
|
24
|
|
- -a="<none>": Author of the image
|
|
25
|
|
- -d="<none>": Description of the image
|
|
26
|
|
- -t="upstart": Type of manager requested
|
|
27
|
71
|
|
|
28
|
72
|
Development
|
|
29
|
|
-===========
|
|
|
73
|
+-----------
|
|
30
|
74
|
|
|
31
|
|
-The image creack/manager:min is a `busybox` base with the binary as entrypoint.
|
|
32
|
|
-It is meant to be light and fast to download.
|
|
|
75
|
+The image ``creack/manager:min`` is a ``busybox`` base with the
|
|
|
76
|
+compiled binary of ``manager.go`` as the :ref:`Entrypoint
|
|
|
77
|
+<entrypoint_def>`. It is meant to be light and fast to download.
|
|
33
|
78
|
|
|
34
|
|
-Now, if you want/need to change or add things, you can download the full
|
|
35
|
|
-creack/manager repository that contains creack/manager:min and
|
|
36
|
|
-creack/manager:dev.
|
|
|
79
|
+If you would like to change or add things, you can download the full
|
|
|
80
|
+``creack/manager`` repository that contains ``creack/manager:min`` and
|
|
|
81
|
+``creack/manager:dev``.
|
|
37
|
82
|
|
|
38
|
|
-The Dockerfiles and the sources are available in `/contrib/host_integration`.
|
|
|
83
|
+The Dockerfiles and the sources are available in
|
|
|
84
|
+`/contrib/host_integration
|
|
|
85
|
+<https://github.com/dotcloud/docker/tree/master/contrib/host_integration>`_.
|
|
39
|
86
|
|
|
40
|
87
|
|
|
41
|
88
|
Upstart
|
|
42
|
|
-=======
|
|
|
89
|
+-------
|
|
|
90
|
+
|
|
|
91
|
+Upstart is the default process manager. The generated script will
|
|
|
92
|
+start the container after the ``docker`` daemon. If the container
|
|
|
93
|
+dies, it will respawn. Start/Restart/Stop/Reload are
|
|
|
94
|
+supported. Reload will send a SIGHUP to the container.
|
|
|
95
|
+
|
|
|
96
|
+Example (``upstart`` on Debian)
|
|
|
97
|
+...............................
|
|
43
|
98
|
|
|
44
|
|
-Upstart is the default process manager. The generated script will start the
|
|
45
|
|
-container after docker daemon. If the container dies, it will respawn.
|
|
46
|
|
-Start/Restart/Stop/Reload are supported. Reload will send a SIGHUP to the container.
|
|
|
99
|
+.. code-block:: bash
|
|
47
|
100
|
|
|
48
|
|
-Example:
|
|
49
|
|
-`CID=$(docker run -d creack/firefo-vnc)`
|
|
50
|
|
-`docker run creack/manager:min -a 'Guillaume J. Charmes <guillaume@dotcloud.com>' -d 'Awesome Firefox in VLC' $CID > /etc/init/firefoxvnc.conf`
|
|
|
101
|
+ CID=$(docker run -d creack/firefo-vnc)
|
|
|
102
|
+ docker run creack/manager:min -a 'Guillaume J. Charmes <guillaume@dotcloud.com>' -d 'Awesome Firefox in VLC' $CID > /etc/init/firefoxvnc.conf
|
|
51
|
103
|
|
|
52
|
|
-You can now do `start firefoxvnc` or `stop firefoxvnc` and if the container
|
|
|
104
|
+You can now ``start firefoxvnc`` or ``stop firefoxvnc`` and if the container
|
|
53
|
105
|
dies for some reason, upstart will restart it.
|
|
54
|
106
|
|
|
55
|
107
|
Systemd
|
|
56
|
|
-=======
|
|
|
108
|
+-------
|
|
|
109
|
+
|
|
|
110
|
+In order to generate a systemd script, we need to use the ``-t``
|
|
|
111
|
+option. The generated script will start the container after docker
|
|
|
112
|
+daemon. If the container dies, it will respawn.
|
|
|
113
|
+``Start/Restart/Reload/Stop`` are supported.
|
|
|
114
|
+
|
|
|
115
|
+Example (``systemd`` on Fedora)
|
|
|
116
|
+...............................
|
|
57
|
117
|
|
|
58
|
|
-In order to generate a systemd script, we need to -t option. The generated
|
|
59
|
|
-script will start the container after docker daemon. If the container dies, it
|
|
60
|
|
-will respawn.
|
|
61
|
|
-Start/Restart/Reload/Stop are supported.
|
|
|
118
|
+.. code-block:: bash
|
|
62
|
119
|
|
|
63
|
|
-Example (fedora):
|
|
64
|
|
-`CID=$(docker run -d creack/firefo-vnc)`
|
|
65
|
|
-`docker run creack/manager:min -t systemd -a 'Guillaume J. Charmes <guillaume@dotcloud.com>' -d 'Awesome Firefox in VLC' $CID > /usr/lib/systemd/system/firefoxvnc.service`
|
|
|
120
|
+ CID=$(docker run -d creack/firefo-vnc)
|
|
|
121
|
+ docker run creack/manager:min -t systemd -a 'Guillaume J. Charmes <guillaume@dotcloud.com>' -d 'Awesome Firefox in VLC' $CID > /usr/lib/systemd/system/firefoxvnc.service
|
|
66
|
122
|
|
|
67
|
|
-You can now do `systemctl start firefoxvnc` or `systemctl stop firefoxvnc`
|
|
68
|
|
-and if the container dies for some reason, systemd will restart it.
|
|
|
123
|
+You can now run ``systemctl start firefoxvnc`` or ``systemctl stop
|
|
|
124
|
+firefoxvnc`` and if the container dies for some reason, ``systemd``
|
|
|
125
|
+will restart it.
|