Manage Docker-Compose With Systemd on Ubuntu

What do we want to achieve?

Easily manage Docker with systemd

Let’s start

Create a generalized service for docker-compose

Create file /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/

Service start

root@vagrant:/home/vagrant# sudo systemctl start docker-compose@wordpress

Conclusion

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.

 by the author.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Maciej

Maciej

623 Followers

DevOps Consultant. I’m strongly focused on automation, security, and reliability.