The Problem:
If you've ever managed more than a couple of Docker Compose projects or standalone containers on a Linux server, you know how quickly things get messy. Data ends up scattered, service management is inconsistent, and onboarding new developers or admins can be slow and error-prone.
How This Helps:
This framework gives you a unified, developer-friendly way to organize, deploy, and manage Docker services. By combining systemd template units, a standardized directory layout, and handy shell utilities, it makes service management predictable, repeatable, and easy to automate.
/srv/container/<service>/
.docker-compose@.service
, docker-container@.service
) let you manage many services with one unit file./srv/container/
<service>/
data/ # Persistent data (volumes, configs, uploads)
docker/ # Compose files, scripts
Step 1: Create Service Directories
create_service_dirs homer
# Creates /srv/container/homer/data and /srv/container/homer/docker
Step 2: Add Your Compose File
Copy your production-ready docker-compose.yml
to /srv/container/homer/docker/
.
sudo cp path/to/docker-compose.yml /srv/container/homer/docker/
Step 3: Map Persistent Data (Relative Path Example)
# /srv/container/homer/docker/docker-compose.yml
services:
homer:
image: b4bz/homer
volumes:
- ../data/www/assets:/www/assets
# ...other options...
All persistent data ends up in /srv/container/homer/data/www/assets
.
Step 4: Enable and Start the Service
compose_systemctl homer enable
compose_systemctl homer start
Or, using systemd directly:
sudo systemctl enable docker-compose@homer.service
sudo systemctl start docker-compose@homer.service
Step 5: Jump to Service Directory
cdcontainer homer
/srv/container
).compose_systemctl <service> status
— Check statuscompose_systemctl <service> restart
— Restart servicecdcontainer <service>
— Jump to service directorydocker-compose@.service
: Manages Compose stacks.docker-container@.service
: Manages single containers.create_service_dirs nextcloud
sudo cp path/to/nextcloud-compose.yml /srv/container/nextcloud/docker/docker-compose.yml
compose_systemctl nextcloud enable
compose_systemctl nextcloud start
compose_systemctl nextcloud stop
sudo systemctl disable docker-compose@nextcloud.service
sudo rm -rf /srv/container/nextcloud
dps
[systemd] <-> [docker-compose@.service] <-> [/srv/container/<service>/docker/docker-compose.yml]
|
+-> [Persistent Data: /srv/container/<service>/data]
sudo journalctl -u docker-compose@<service>.service
/srv/container/<service>/docker
and /srv/container/<service>/data
exist and have correct permissions.docker-compose.yml
.cdcontainer
: .bash_functions
is sourced in your shell.compose_systemctl <service> status
for quick health checks.docker logs <container>
for container-level debugging.ll /srv/container/<service>/data
to inspect persistent files.create_service_dirs
).Q: Can I use Podman instead of Docker?
A: Yes, with minor changes to the systemd unit files and Compose commands.
Q: How do I back up all my service data?
A: Back up /srv/container
— all persistent data lives there.
Q: How do I add custom environment variables or ports?
A: Edit your service's docker-compose.yml
in /srv/container/<service>/docker/
.