From c8a99a5054b2f890d56eda15adf478d4e70612b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tadej=20Jane=C5=BE?= Date: Wed, 22 Jun 2016 10:00:56 +0200 Subject: [PATCH] Expand instructions on using systemd to manage containers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tadej Janež --- docs/admin/host_integration.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/admin/host_integration.md b/docs/admin/host_integration.md index 3f71592c46..e7964b6de0 100644 --- a/docs/admin/host_integration.md +++ b/docs/admin/host_integration.md @@ -76,6 +76,10 @@ a new service that will be started after the docker daemon service has started. [Install] WantedBy=local.target +If you intend to use this as a system service, put the above contents in a file +in the `/etc/systemd/system` directory, e.g. +`/etc/systemd/system/docker-redis_server.service`. + 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 @@ -86,3 +90,12 @@ and removed when the service is stopped. 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 ... + +To start using the service, reload systemd and start the service: + + systemctl daemon-reload + systemctl start docker-redis_server.service + +To enable the service at system startup, execute: + + systemctl enable docker-redis_server.service