Manage Docker-Compose With Systemd on Ubuntu

Photo by Pablo Arroyo on Unsplash

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.

--

--

--

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

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Transferring UST from Osmosis to TerraStation

How to Make Skeleton Loaders

Unofficial guide to Tailwind and ActionText for Rails 6

Your new pretty and minimalist resume with LaTex

Solution: In No Particular Order…

My Second Month Report of GSoC 2020

Cynefin in Space — A new dimension and the impact of gravity

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

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

More from Medium

Docker & Nginx & Logs

Using Windows Subsystem for Linux for Kubernetes

Understanding container networking using Linux network namespaces and a virtual switch to isolate…

🗃 Containerization & Docker Fundamentals