What do we want to achieve?
Easily manage Docker with systemd
Create a generalized service for docker-compose
/etc/systemd/system/docker-compose@.service The name of this file is important, so basically don’t change it.
Nothing happens with this alone. This is like a service template for Docker-compose
Create a folder to put the actual docker-compose & put docker-compose.yml.
🚨 When you put the file, be sure
docker-compose.yml to put it in!
As you can see from the Service above, multiple docker-compose.yml are placed in different Dirctory & generalized by changing the Working Directory, so docker-compose.yml the name cannot be changed.
root@vagrant:/home/vagrant# wget https://gist.github.com/spy86/2413ad5621de106b906cf7b0be047328
root@vagrant:/home/vagrant# sudo mkdir -p /etc/docker/compose/wordpress
root@vagrant:/home/vagrant# cp docker-compose.yaml /etc/docker/compose/wordpress/
root@vagrant:/home/vagrant# sudo systemctl start docker-compose@wordpress
If you get an error
sudo journalctl -xe, try it, but it’s hard to understand, so it’s quick to actually check the command.