Parcourir la source

Merge pull request #10723 from SvenDowideit/takeover-10653

Update sample systemd for container
Jessie Frazelle il y a 10 ans
Parent
commit
44e9715e46
1 fichiers modifiés avec 12 ajouts et 2 suppressions
  1. 12 2
      docs/sources/articles/host_integration.md

+ 12 - 2
docs/sources/articles/host_integration.md

@@ -59,12 +59,11 @@ a new service that will be started after the docker daemon service has started.
       /usr/bin/docker start -a redis_server
     end script
 
-
 ### systemd
 
     [Unit]
     Description=Redis container
-    Author=Me
+    Requires=docker.service
     After=docker.service
 
     [Service]
@@ -74,3 +73,14 @@ a new service that will be started after the docker daemon service has started.
 
     [Install]
     WantedBy=local.target
+
+If you need to pass options to the redis container (such as `--env`),
+then you'll need to use `docker run` rather than `docker start`. This will
+create a new container every time the service is started, which will be stopped
+and removed when the service is stopped.
+
+    [Service]
+    ...
+    ExecStart=/usr/bin/docker run --env foo=bar --name redis_server redis
+    ExecStop=/usr/bin/docker stop -t 2 redis_server ; /usr/bin/docker rm -f redis_server
+    ...