Merge pull request #10723 from SvenDowideit/takeover-10653
Update sample systemd for container Upstream-commit: 44e9715e46db46d9c88b5bba6072c0fe42aa5837 Component: engine
This commit is contained in:
@@ -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
|
||||
...
|
||||
|
||||
Reference in New Issue
Block a user