Browse code

update systemd article to reference dropin file

Signed-off-by: Jessica Frazelle <acidburn@docker.com>

Jessica Frazelle authored on 2015/08/05 01:47:48
Showing 1 changed files
... ...
@@ -33,17 +33,33 @@ If you want Docker to start at boot, you should also:
33 33
 There are a number of ways to configure the daemon flags and environment variables
34 34
 for your Docker daemon.
35 35
 
36
-If the `docker.service` file is set to use an `EnvironmentFile`
37
-(often pointing to `/etc/sysconfig/docker`) then you can modify the
38
-referenced file.
36
+The recommended way is to use a systemd drop-in file. These are local files in
37
+the `/etc/systemd/system/docker.service.d` directory. This could also be
38
+`/etc/systemd/system/docker.service`, which also works for overriding the
39
+defaults from `/lib/systemd/system/docker.service`.
39 40
 
40
-Check if the `docker.service` uses an `EnvironmentFile`:
41
+However, if you had previously used a package which had an `EnvironmentFile`
42
+(often pointing to `/etc/sysconfig/docker`) then for backwards compatibility,
43
+you drop a file in the `/etc/systemd/system/docker.service.d`
44
+directory including the following:
45
+
46
+    [Service]
47
+    EnvironmentFile=-/etc/sysconfig/docker
48
+    EnvironmentFile=-/etc/sysconfig/docker-storage
49
+    EnvironmentFile=-/etc/sysconfig/docker-network
50
+    ExecStart=
51
+    ExecStart=/usr/bin/docker -d -H fd:// $OPTIONS \
52
+              $DOCKER_STORAGE_OPTIONS \
53
+              $DOCKER_NETWORK_OPTIONS \
54
+              $BLOCK_REGISTRY \
55
+              $INSECURE_REGISTRY
56
+
57
+To check if the `docker.service` uses an `EnvironmentFile`:
41 58
 
42 59
     $ sudo systemctl show docker | grep EnvironmentFile
43 60
     EnvironmentFile=-/etc/sysconfig/docker (ignore_errors=yes)
44 61
 
45
-Alternatively, find out where the service file is located, and look for the
46
-property:
62
+Alternatively, find out where the service file is located:
47 63
 
48 64
     $ sudo systemctl status docker | grep Loaded
49 65
        Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled)
... ...
@@ -69,18 +85,20 @@ In this example, we'll assume that your `docker.service` file looks something li
69 69
 
70 70
     [Service]
71 71
     Type=notify
72
-    EnvironmentFile=-/etc/sysconfig/docker
73
-    ExecStart=/usr/bin/docker daemon -H fd:// $OPTIONS
72
+    ExecStart=/usr/bin/docker daemon -H fd://
74 73
     LimitNOFILE=1048576
75 74
     LimitNPROC=1048576
76 75
 
77 76
     [Install]
78 77
     Also=docker.socket
79 78
 
80
-This will allow us to add extra flags to the `/etc/sysconfig/docker` file by
81
-setting `OPTIONS`:
79
+This will allow us to add extra flags via a drop-in file (mentioned above) by
80
+placing a file containing the following in the `/etc/systemd/system/docker.service.d`
81
+directory:
82 82
 
83
-    OPTIONS="--graph /mnt/docker-data --storage-driver btrfs"
83
+    [Service]
84
+    ExecStart=
85
+    ExecStart=/usr/bin/docker daemon -H fd:// --graph /mnt/docker-data --storage-driver btrfs
84 86
 
85 87
 You can also set other environment variables in this file, for example, the
86 88
 `HTTP_PROXY` environment variables described below.