Run Hangar with Docker¶
One container, with SQLite and the filesystem Blob store in a volume.
docker run -d --name hangar -p 8080:8080 -v hangar:/var/lib/hangar \
-e HANGAR_SERVER_PUBLIC_URL=http://localhost:8080 \
ghcr.io/hangar-hub/hangar:latest
HANGAR_SERVER_PUBLIC_URL is the URL clients use to reach Hangar. It appears in git URLs, LFS links and redirects, so set it to the address your users type, such as https://hangar.example.com behind a reverse proxy.
On the first start Hangar generates an Instance key and a password for the first admin and saves them in /var/lib/hangar/secrets.yaml (mode 0600). The container log names the file but never holds the secrets, because log collectors can read it. The image has no shell, so copy the password out of the volume with docker cp:
docker cp hangar:/var/lib/hangar/secrets.yaml - | tar -xO | grep bootstrap_admin_password
bootstrap_admin_password: XLhYPMrxhrVxjJDFmpPcPtVy
The file also holds instance_key. Keep a copy of it: it encrypts stored secrets such as upstream tokens and webhook secrets. Later starts read both from the file.
The image¶
ghcr.io/hangar-hub/hangar:<version>and:latest, forlinux/amd64andlinux/arm64, signed with cosign (see Security hardening).- It runs as UID 65532 with no shell, and works with a read-only root filesystem when
/tmpand/var/cache/hangarare writable:
docker run -d --name hangar -p 8080:8080 -v hangar:/var/lib/hangar \
--read-only --tmpfs /tmp --tmpfs /var/cache/hangar:uid=65532,gid=65532 \
-e HANGAR_SERVER_PUBLIC_URL=http://localhost:8080 \
ghcr.io/hangar-hub/hangar:latest
- Data lives in
/var/lib/hangar, the git pack cache in/var/cache/hangar. - The image has a
HEALTHCHECKthat runshangar healthcheck, which calls/readyz.
Configuration¶
Every configuration key is also an environment variable: storage.s3.bucket is HANGAR_STORAGE_S3_BUCKET. To use a file instead, mount it at /etc/hangar/hangar.yaml, where the image reads it (the image sets HANGAR_CONFIG to that path). Environment variables override the file.
docker run -d --name hangar -p 8080:8080 -v hangar:/var/lib/hangar \
-v "$PWD/hangar.yaml:/etc/hangar/hangar.yaml:ro" \
ghcr.io/hangar-hub/hangar:latest
Every key is listed in the configuration reference. Hangar refuses to start if a HANGAR_ variable is not one of them, so a misspelt name shows up at once; see Troubleshooting.
Next: First sign-in.