Difference between revisions of "Work-Adventure/install/Add docker-compose as systemd unit"

From Technologia Incognita
Jump to: navigation, search
(Created page with ":: → Source: https://gist.github.com/mosquito/b23e1c1e5723a7fd9e6568e5cf91180f == Docker compose as a systemd unit == Create file <code>/etc/systemd/system/docker-compose@...")
 
(Docker compose as a systemd unit)
Line 3: Line 3:
 
== Docker compose as a systemd unit ==
 
== Docker compose as a systemd unit ==
  
Create file <code>/etc/systemd/system/docker-compose@.service</code>.  
+
SystemD calling binaries using an absolute path. In my case is prefixed by <code>/usr/bin</code>, you should use paths specific for your environment.
  
SystemD calling binaries using an absolute path. In my case is prefixed by <code>/usr/bin</code>, you should use paths specific for your environment.
+
Create <code>/etc/systemd/system/docker-compose@.service</code>:
  
 
<pre>
 
<pre>

Revision as of 03:49, 20 March 2021

→ Source: https://gist.github.com/mosquito/b23e1c1e5723a7fd9e6568e5cf91180f

Docker compose as a systemd unit

SystemD calling binaries using an absolute path. In my case is prefixed by /usr/bin, you should use paths specific for your environment.

Create /etc/systemd/system/docker-compose@.service:

[Unit]
Description=%i service with docker compose
Requires=docker.service
After=docker.service

[Service]
Type=oneshot
RemainAfterExit=true
WorkingDirectory=/opt/docker/compose/%i
ExecStart=/usr/bin/docker-compose up -d --remove-orphans
ExecStop=/usr/bin/docker-compose down

[Install]
WantedBy=multi-user.target

Place your docker-compose.yaml and .env files into /opt/docker/compose/myservice and call

systemctl start docker-compose@myservice