4 ms·
Is there any reason not to use Docker instead of systemd? I like managing services with a simple docker-compose.yml on my server. It has worked great so far but
by paulkre 3y ago
Is there any reason not to use Docker instead of systemd? I like managing services with a simple docker-compose.yml on my server. It has worked great so far but I wonder if there are some downsides that I am not aware of. Performance doesn’t seem to be an issue, right?
- spenczar5 3y agoThey don’t quite do the same things. Systemd will do stuff like ensure the service is restarted if it ever crashes. It can also make sure system-level dependencies are up and running (“service B depends on service A, so wait for A to be up before trying to start B”). Performance is not an issue in most docker setups you would ever use, correct.
- WhatsName 3y agoAcutally, there are docker-compose primitives that solve just that (restart: always/on-failure and depends-on: servicename. I think it mostly comes down to what layer of abstraction you like working at.
- BossingAround 3y agoPodman can generate systemd units for managing containers IIRC.
- MonkeyClub 3y agoYep, that's right: https://docs.podman.io/en/latest/markdown/podman-generate-systemd.1.html https://docs.podman.io/en/latest/markdown/podman-generate-sy...
- stryan 3y agoProblem is you can't have it depend on anything outside of docker i.e. I can't write a docker-compose file that waits for an NFS mount.
- spenczar5 3y agoTrue, Docker-compose has a lot more overlap with systemd. But it doesn’t have system-level dependencies. For example, in systemd I can wait for a network interface to be up and have an IP assigned by DHCP. As far as I am aware, docker compose knows about the docker network and its own containers, but not the system more broadly. Also, you will likely want it to run for a long time, so something has to trigger the docker-compose process to start and restart it. You might want it to restart in case the OOM killer knocks it over. That daemom stuff is what systemd is good for.
- stasmo 3y agoNo not really any reason. Docker has a bit of overhead but greatly simplifies most of the things the author is doing manually with his self-described “better than the vast majority of off the shelf solutions” software.
- trufas 3y agoHow is setting up a Dockerfile and then a docker-compose file any simpler than just writing a unit file? This seems like a perfect application of the init system.
- c-hendricks 3y agoI use docker-compose + systemd. systemd has come in clutch when you need to add waiting for another service to come up. I should really put my homelab setup somewhere.
- john-shaffer 3y agoPerformance with Docker is slightly worse, but it shouldn't be an issue for a long-running process. The main problem I've run into is that, by default, Docker logs will eventually fill the disk and crash the server. You have to change the logging system and then delete and recreate all of your containers, because there is no way to change the logging system for existing containers.
- AlexITC 3y agoThe author focuses on simplicity, he tries to handle everything with a single file for the app + a single file for the database. Unnecessary overhead gets introduced with docker, for example, now you need to depend on a container-registry + the authentication to pull those images from the server + other stuff.
- killthebuddha 3y agoFWIW there are tons of ways to use Docker without an image (I assume you meant image) registry. If you're running Docker on the server you're deploying to then that's all you need.
- AlexITC 3y agoI guess, still, the image needs to be built somewhere, my bet is that you will do this on the server itself, its unnecessary complexity.