mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #23844 from tjanez/docs-systemd-expand
Expand instructions on using systemd to manage containers
This commit is contained in:
commit
42f2205184
1 changed files with 13 additions and 0 deletions
|
@ -76,6 +76,10 @@ a new service that will be started after the docker daemon service has started.
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=default.target
|
WantedBy=default.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`),
|
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
|
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
|
create a new container every time the service is started, which will be stopped
|
||||||
|
@ -87,3 +91,12 @@ and removed when the service is stopped.
|
||||||
ExecStop=/usr/bin/docker stop -t 2 redis_server
|
ExecStop=/usr/bin/docker stop -t 2 redis_server
|
||||||
ExecStopPost=/usr/bin/docker rm -f redis_server
|
ExecStopPost=/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
|
||||||
|
|
Loading…
Add table
Reference in a new issue