mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #10723 from SvenDowideit/takeover-10653
Update sample systemd for container
This commit is contained in:
commit
44e9715e46
1 changed files with 12 additions and 2 deletions
|
@ -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
|
/usr/bin/docker start -a redis_server
|
||||||
end script
|
end script
|
||||||
|
|
||||||
|
|
||||||
### systemd
|
### systemd
|
||||||
|
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Redis container
|
Description=Redis container
|
||||||
Author=Me
|
Requires=docker.service
|
||||||
After=docker.service
|
After=docker.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
|
@ -74,3 +73,14 @@ a new service that will be started after the docker daemon service has started.
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=local.target
|
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
|
||||||
|
...
|
||||||
|
|
Loading…
Add table
Reference in a new issue