# Moving a systemd install to a container This runbook moves a running systemd install (see Production install in [operations.md](operations.md)) to the container image (see Running in a container). It was rehearsed with rootless Docker on a copy of a production database, with the network disabled and the pipeline off. Placeholders: `` is the systemd install root, `IMAGE` the image, `DATA` and `CONFIG` the volumes mounted at `/data` and `/config`. The `docker run` lines show the shared options as `$RUN`: ``` RUN="-v DATA:/data -v CONFIG:/config --env-file container.env" ``` `container.env` holds `AUTOCRAFT_BASE_URL`, `AUTOCRAFT_TRUST_PROXY` and any other setting from the systemd settings file that is not a path. Do not copy the path settings (`AUTOCRAFT_DB`, `AUTOCRAFT_SECRETS_FILE`, cache and lock directories, listen addresses): the image sets them. Steps marked **admin** need a person with access to the secrets or to DNS and the proxy. ## Before the window 1. **admin**: Build or pull the image and start it once with `--network none` against an empty volume to check that it runs (`IMAGE pipeline status`). 2. **admin**: Decide where the dashboard is reachable and keep the DNS and reverse-proxy change ready. `AUTOCRAFT_BASE_URL` must be the public origin; the GitHub App's callback and setup URLs and the OAuth app's callback URL must match it (see Moving to a new domain in [deploy-checklist.md](deploy-checklist.md)). 3. Check the free space of the target volume: the database plus its newest backup (a 1.2 GB database restored in under 10 s). ## Cut-over 1. **Pipeline off.** On the old host: `autocraft pipeline off`. Wait until the runner has no running job (`autocraft pipeline status`, or the jobs list on the dashboard). `pipeline off` holds only automatic jobs: jobs queued by a user or the CLI stay queued and would start on the new runner. List them with `autocraft runner jobs --state queued` and cancel each with `autocraft runner cancel `. Check that the list is empty before the final backup. 2. **Final backup.** `deploy/backup.sh predeploy` (with the systemd settings loaded). It writes `/backups/predeploy-.db.zst` from a consistent snapshot and checks its integrity. Keep the file name. 3. **Stop the old services**: the runner, the dashboard, the sync and backup timers. Nothing may write to the old database from now on. Do not delete anything on the old host. 4. **Create the volumes** and make `/data` and `/config` writable by uid 10001. With Docker, named volumes take that ownership from the image. In Kubernetes, `fsGroup: 10001` does it. 5. **Restore the database** into the data volume. Stream the backup through a container so no host permissions are involved (the volume belongs to uid 10001, and under rootless Docker the host cannot read it): ``` zstd -dc predeploy-