From 9059cf0db5259d9cddf59486c2b91eeffa78b7b6 Mon Sep 17 00:00:00 2001 From: Daniel YC Lin Date: Mon, 9 Feb 2015 16:25:42 +0800 Subject: [PATCH 1/2] 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 Upstream-commit: 8c19e43dff7d46e6213eac512d44bb2582d1c959 Component: engine --- .../docs/sources/articles/host_integration.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/components/engine/docs/sources/articles/host_integration.md b/components/engine/docs/sources/articles/host_integration.md index 89fd2a1f7a..cda86688e8 100644 --- a/components/engine/docs/sources/articles/host_integration.md +++ b/components/engine/docs/sources/articles/host_integration.md @@ -59,18 +59,27 @@ 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] Restart=always ExecStart=/usr/bin/docker start -a redis_server + # for more options, use 'run' instead of 'start', but not suggested + # ExecStart=/usr/bin/docker run redis_server ExecStop=/usr/bin/docker stop -t 2 redis_server [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'. + + [Service] + ... + ExecStart=/usr/bin/docker run --env foo=bar redis_server + ... From bbfbec00cd19ac4853a3111c92bad4d2ae8bda50 Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Thu, 12 Feb 2015 13:02:54 +1000 Subject: [PATCH 2/2] tweak the prose a little Signed-off-by: Sven Dowideit Upstream-commit: 814916457b50082e4299691ae92b4ed368ddb076 Component: engine --- .../engine/docs/sources/articles/host_integration.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/components/engine/docs/sources/articles/host_integration.md b/components/engine/docs/sources/articles/host_integration.md index cda86688e8..cbcb21a357 100644 --- a/components/engine/docs/sources/articles/host_integration.md +++ b/components/engine/docs/sources/articles/host_integration.md @@ -69,17 +69,18 @@ a new service that will be started after the docker daemon service has started. [Service] Restart=always ExecStart=/usr/bin/docker start -a redis_server - # for more options, use 'run' instead of 'start', but not suggested - # ExecStart=/usr/bin/docker run redis_server ExecStop=/usr/bin/docker stop -t 2 redis_server [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'. +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 redis_server + 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 ...