Browse code

Update sample systemd for container

1. Docker require to run before redis container run.
2. 'start' command can not accept more options like "run -e xx ..."
3. Remove wrong command 'Author='

Signed-off-by: Daniel YC Lin <dlin.tw@gmail>

Daniel YC Lin authored on 2015/02/09 17:25:42
Showing 1 changed files
... ...
@@ -59,18 +59,27 @@ a new service that will be started after the docker daemon service has started.
59 59
       /usr/bin/docker start -a redis_server
60 60
     end script
61 61
 
62
-
63 62
 ### systemd
64 63
 
65 64
     [Unit]
66 65
     Description=Redis container
67
-    Author=Me
66
+    Requires=docker.service
68 67
     After=docker.service
69 68
 
70 69
     [Service]
71 70
     Restart=always
72 71
     ExecStart=/usr/bin/docker start -a redis_server
72
+    # for more options, use 'run' instead of 'start', but not suggested
73
+    # ExecStart=/usr/bin/docker run redis_server
73 74
     ExecStop=/usr/bin/docker stop -t 2 redis_server
74 75
 
75 76
     [Install]
76 77
     WantedBy=local.target
78
+
79
+if you need to pass options to the redis container (such as '--env'), 
80
+then you'll need to use 'docker run' rather than 'docker start'.
81
+
82
+    [Service]
83
+    ...
84
+    ExecStart=/usr/bin/docker run --env foo=bar redis_server
85
+    ...