Systemd Integration
Fleet creates a systemd service unit for each registered app. This gives you systemctl start/stop/restart, boot ordering, automatic restart on failure, and dependency management.
How it works
When you run fleet deploy <app>, fleet:
- Generates a
.serviceunit file from the app’s registry entry - Writes it to
/etc/systemd/system/<serviceName>.service - Runs
systemctl daemon-reload - Enables and starts the service
The service unit uses Type=oneshot with RemainAfterExit=yes — it runs docker compose up -d on start and docker compose down on stop.
Generated service file
[Unit]Description=myapp (fleet-managed)Requires=docker.serviceAfter=docker.service network-online.targetWants=network-online.target
[Service]Type=oneshotRemainAfterExit=yesWorkingDirectory=/opt/apps/myappExecStartPre=-/usr/bin/docker compose downExecStart=/usr/bin/docker compose up -d --force-recreateExecStop=/usr/bin/docker compose down --timeout 30ExecReload=/usr/bin/docker compose restartTimeoutStartSec=300TimeoutStopSec=60Restart=on-failureRestartSec=10
[Install]WantedBy=multi-user.targetDatabase dependency
If an app has dependsOnDatabases: true in its registry entry, the unit adds:
Requires=docker.service docker-databases.serviceAfter=docker.service docker-databases.service network-online.targetThis ensures your database containers are running before the app starts.
Custom compose file
If the app specifies a composeFile, the unit adds the -f flag:
ExecStart=/usr/bin/docker compose -f "docker-compose.prod.yml" up -d --force-recreateBoot order
Fleet manages boot ordering through systemd dependencies:
docker.servicestarts first (system-provided)docker-databases.servicestarts (if you have shared databases)- App services start (after their dependencies)
fleet-unseal.servicedecrypts secrets before apps that need them
Common operations
# Check if systemd is availablesystemctl is-system-running
# View fleet-managed service statussudo fleet status
# Restart a specific appsudo fleet restart myapp
# View service logs via journalctljournalctl -u fleet-myapp.service -fPrivilege requirements
All systemd operations require root. The fleet start, fleet stop, fleet restart, and fleet deploy commands check for root and exit with a clear error if not running as root.
Patching existing services
If you modify an app’s registry entry (change compose file, add database dependency), run:
sudo fleet patch-systemd myappThis regenerates the service file and reloads the systemd daemon without restarting the app.