Igor Bubelov About Blog Photos

Docker Compose and Systemd

August 28, 2021

There are many good reasons why Docker Compose is popular among developers and self-hosting enthusiasts. It may lack some features of a “world scale” orchestrator, but it’s much easier to use and configure than something like Kubernetes. I tended to use Docker Compose pretty much everywhere up until recently, but now I prefer Systemd. It may sound like comparing apples to oranges, but Systemd can do a lot of things Docker Compose does in a much cleaner fashion.

The thing is: if you have a Linux server, it’s probably based on Systemd, and there might be no good reasons to install any additional dependencies. Avoiding extra dependencies isn’t the only reason to stick with Systemd, though. Generally, installing two invasive systems competing to do the same thing is a recipe for a disaster. Many Docker Compose users are unaware about the fact that it messes with their firewalls, and many learned about it the hard way. Up until recently, even installing Docker Compose on something not too mainstream, like Raspberry Pi, was so nuanced and confusing that it deserved a special post in this blog. Finally, it’s impossible to avoid Systemd nowadays, but it’s pretty easy to avoid Docker Compose, so why clutter your mind with two things when you can get away with just one?

Docker itself (without Compose) is very handy when you need to deploy something extremely complicated (often, for no good reason). For instance, Nextcloud is essentially a bunch of PHP scripts which require a lot of dependencies and some painful manual setup. It could have been a simple executable, but it’s not. That’s where Docker shines: it allows us to hide messy to deploy software behind a simple CLI. Setting things up is a hard job which might need deep expertise. Docker can abstract that away, just give it a port to bind to, and it’ll take care of the rest. Go and Rust have set a good trend of packing everything into a single binary, which obsoletes many of the Docker use cases, especially for the typical single-node self-hosted deployments. I hope more software will be distributed like this in the future, but for now, it’s pretty much impossible to avoid Docker.