Browse code

Extract the systemd docs from various places and add a little more

Signed-off-by: Sven Dowideit <SvenDowideit@docker.com>

Sven Dowideit authored on 2014/11/26 13:09:52
Showing 10 changed files
... ...
@@ -98,6 +98,7 @@ pages:
98 98
 - ['articles/ambassador_pattern_linking.md', 'Articles', 'Cross-Host linking using ambassador containers']
99 99
 - ['articles/runmetrics.md', 'Articles', 'Runtime metrics']
100 100
 - ['articles/b2d_volume_resize.md', 'Articles', 'Increasing a Boot2Docker volume']
101
+- ['articles/systemd.md', 'Articles', 'Controlling and configuring Docker using Systemd']
101 102
 
102 103
 # Reference
103 104
 - ['reference/index.md', '**HIDDEN**']
104 105
new file mode 100644
... ...
@@ -0,0 +1,101 @@
0
+page_title: Controlling and configuring Docker using Systemd
1
+page_description: Controlling and configuring Docker using Systemd
2
+page_keywords: docker, daemon, systemd, configuration
3
+
4
+# Controlling and configuring Docker using Systemd
5
+
6
+Many Linux distributions use systemd to start the Docker daemon. This document
7
+shows a few examples of how to customise Docker's settings.
8
+
9
+## Starting the Docker daemon
10
+
11
+Once Docker is installed, you will need to start the Docker daemon.
12
+
13
+    $ sudo systemctl start docker
14
+    # or on older distributions, you may need to use
15
+    $ sudo service docker start
16
+
17
+If you want Docker to start at boot, you should also:
18
+
19
+    $ sudo systemctl enable docker
20
+    # or on older distributions, you may need to use
21
+    $ sudo chkconfig docker on
22
+
23
+## Custom Docker daemon options
24
+
25
+There are a number of ways to configure the daemon flags and environment variables
26
+for your Docker daemon. 
27
+
28
+If the `docker.service` file is set to use an `EnvironmentFile`
29
+(often pointing to `/etc/sysconfig/docker`) then you can modify the
30
+referenced file.
31
+
32
+Or, you may need to edit the `docker.service` file, which can be in `/usr/lib/systemd/system`
33
+or `/etc/systemd/service`.
34
+
35
+### Runtime directory and storage driver
36
+
37
+You may want to control the disk space used for Docker images, containers
38
+and volumes by moving it to a separate partition.
39
+
40
+In this example, we'll assume that your `docker.services` file looks something like:
41
+
42
+    [Unit]
43
+    Description=Docker Application Container Engine
44
+    Documentation=http://docs.docker.com
45
+    After=network.target docker.socket
46
+    Requires=docker.socket
47
+    
48
+    [Service]
49
+    Type=notify
50
+    EnvironmentFile=-/etc/sysconfig/docker
51
+    ExecStart=/usr/bin/docker -d -H fd:// $OPTIONS
52
+    LimitNOFILE=1048576
53
+    LimitNPROC=1048576
54
+    
55
+    [Install]
56
+    Also=docker.socket
57
+
58
+This will allow us to add extra flags to the `/etc/sysconfig/docker` file by
59
+setting `OPTIONS`:
60
+
61
+    OPTIONS="--graph /mnt/docker-data --storage btrfs"
62
+
63
+You can also set other environment variables in this file, for example, the
64
+`HTTP_PROXY` environment variables described below.
65
+
66
+### HTTP Proxy
67
+
68
+This example overrides the default `docker.service` file.
69
+
70
+If you are behind a HTTP proxy server, for example in corporate settings, 
71
+you will need to add this configuration in the Docker systemd service file.
72
+
73
+Copy file `/usr/lib/systemd/system/docker.service` to `/etc/systemd/system/docker/service`.
74
+
75
+Add the following to the `[Service]` section in the new file:
76
+
77
+    Environment="HTTP_PROXY=http://proxy.example.com:80/"
78
+
79
+If you have internal Docker registries that you need to contact without
80
+proxying you can specify them via the `NO_PROXY` environment variable:
81
+
82
+    Environment="HTTP_PROXY=http://proxy.example.com:80/" "NO_PROXY=localhost,127.0.0.0/8,docker-registry.somecorporation.com"
83
+
84
+Flush changes:
85
+
86
+    $ sudo systemctl daemon-reload
87
+    
88
+Restart Docker:
89
+
90
+    $ sudo systemctl restart docker
91
+
92
+## Manually creating the systemd unit files
93
+
94
+When installing the binary without a package, you may want
95
+to integrate Docker with systemd. For this, simply install the two unit files
96
+(service and socket) from [the github
97
+repository](https://github.com/docker/docker/tree/master/contrib/init/systemd)
98
+to `/etc/systemd/system`.
99
+
100
+
... ...
@@ -53,3 +53,9 @@ service:
53 53
 To start on system boot:
54 54
 
55 55
     $ sudo systemctl enable docker
56
+
57
+## Custom daemon options
58
+
59
+If you need to add an HTTP Proxy, set a different directory or partition for the
60
+Docker runtime files, or make other customizations, read our systemd article to
61
+learn how to [customize your systemd Docker daemon options](/articles/systemd/).
... ...
@@ -45,11 +45,11 @@ to `/etc/systemd/system`.
45 45
 CentOS-7 introduced firewalld, which is a wrapper around iptables and can
46 46
 conflict with Docker.
47 47
 
48
-When firewalld is started or restarted it will remove the `DOCKER` chain
48
+When `firewalld` is started or restarted it will remove the `DOCKER` chain
49 49
 from iptables, preventing Docker from working properly.
50 50
 
51
-When using systemd, firewalld is started before Docker, but if you
52
-start or restart firewalld  after Docker, you will have to restart the Docker daemon.
51
+When using systemd, `firewalld` is started before Docker, but if you
52
+start or restart `firewalld` after Docker, you will have to restart the Docker daemon.
53 53
 
54 54
 ## Installing Docker - CentOS-6
55 55
 Please note that this for CentOS-6, this package is part of [Extra Packages
... ...
@@ -103,7 +103,13 @@ Run a simple bash shell to test the image:
103 103
     $ sudo docker run -i -t centos /bin/bash
104 104
 
105 105
 If everything is working properly, you'll get a simple bash prompt. Type
106
-exit to continue.
106
+`exit` to continue.
107
+
108
+## Custom daemon options
109
+
110
+If you need to add an HTTP Proxy, set a different directory or partition for the
111
+Docker runtime files, or make other customizations, read our systemd article to
112
+learn how to [customize your systemd Docker daemon options](/articles/systemd/).
107 113
 
108 114
 ## Dockerfiles
109 115
 The CentOS Project provides a number of sample Dockerfiles which you may use
... ...
@@ -67,28 +67,11 @@ member of that group in order to contact the `docker -d` process.
67 67
 Adding users to the `docker` group is *not* necessary for Docker versions 1.0
68 68
 and above.
69 69
 
70
-## HTTP Proxy
70
+## Custom daemon options
71 71
 
72
-If you are behind a HTTP proxy server, for example in corporate settings, 
73
-you will need to add this configuration in the Docker *systemd service file*.
74
-
75
-Edit file `/usr/lib/systemd/system/docker.service`. Add the following to
76
-section `[Service]` :
77
-
78
-    Environment="HTTP_PROXY=http://proxy.example.com:80/"
79
-
80
-If you have internal Docker registries that you need to contact without
81
-proxying you can specify them via the `NO_PROXY` environment variable:
82
-
83
-    Environment="HTTP_PROXY=http://proxy.example.com:80/" "NO_PROXY=localhost,127.0.0.0/8,docker-registry.somecorporation.com"
84
-
85
-Flush changes:
86
-
87
-    $ systemctl daemon-reload
88
-    
89
-Restart Docker:
90
-
91
-    $ systemctl start docker
72
+If you need to add an HTTP Proxy, set a different directory or partition for the
73
+Docker runtime files, or make other customizations, read our systemd article to
74
+learn how to [customize your systemd Docker daemon options](/articles/systemd/).
92 75
 
93 76
 ## What next?
94 77
 
... ...
@@ -42,3 +42,9 @@ service:
42 42
 To start on system boot:
43 43
 
44 44
     $ sudo systemctl enable lxc-docker
45
+
46
+## Custom daemon options
47
+
48
+If you need to add an HTTP Proxy, set a different directory or partition for the
49
+Docker runtime files, or make other customizations, read our systemd article to
50
+learn how to [customize your systemd Docker daemon options](/articles/systemd/).
... ...
@@ -91,3 +91,7 @@ To start the `docker` daemon:
91 91
 To start on system boot:
92 92
 
93 93
     $ sudo systemctl enable docker
94
+   
95
+If you need to add an HTTP Proxy, set a different directory or partition for the
96
+Docker runtime files, or make other customizations, read our systemd article to
97
+learn how to [customize your systemd Docker daemon options](/articles/systemd/).
... ...
@@ -71,5 +71,13 @@ hand to ensure the `FW_ROUTE` flag is set to `yes` like so:
71 71
 
72 72
 **Done!**
73 73
 
74
+## Custom daemon options
75
+
76
+If you need to add an HTTP Proxy, set a different directory or partition for the
77
+Docker runtime files, or make other customizations, read our systemd article to
78
+learn how to [customize your systemd Docker daemon options](/articles/systemd/).
79
+
80
+## What's next
81
+
74 82
 Continue with the [User Guide](/userguide/).
75 83
 
... ...
@@ -75,6 +75,12 @@ and set `enabled=1` in the `[ol6_addons]` or the `[ol7_addons]` stanza.
75 75
 
76 76
 **Done!**
77 77
 
78
+## Custom daemon options
79
+
80
+If you need to add an HTTP Proxy, set a different directory or partition for the
81
+Docker runtime files, or make other customizations, read our systemd article to
82
+learn how to [customize your systemd Docker daemon options](/articles/systemd/).
83
+
78 84
 ## Using the btrfs storage engine
79 85
 
80 86
 Docker on Oracle Linux 6 and 7 supports the use of the btrfs storage engine.
... ...
@@ -83,6 +83,13 @@ Now let's verify that Docker is working.
83 83
 
84 84
 Continue with the [User Guide](/userguide/).
85 85
 
86
+## Custom daemon options
87
+
88
+If you need to add an HTTP Proxy, set a different directory or partition for the
89
+Docker runtime files, or make other customizations, read our systemd article to
90
+learn how to [customize your systemd Docker daemon options](/articles/systemd/).
91
+
92
+
86 93
 ## Issues?
87 94
 
88 95
 If you have any issues - please report them directly in the