Deploy a Docker image

Run a prebuilt Docker image on Hangar from Docker Hub, GHCR or a private registry, and redeploy it from your CI with a deploy hook.

Updated

If you already build your app into an image, in GitHub Actions, GitLab CI or anywhere else, Hangar can run that image as it is. There is no build step on Hangar: it pulls the image and starts it.

Set the image

Add a service and choose Docker image as its source. Enter the image reference, for example:

ghcr.io/acme/api:latest

Any public image works as it is. For a private registry, also enter the registry URL, such as ghcr.io, with a username and a password or token. Prefer a token with read-only access to the registry.

Changes to the image apply on the next deployment.

Deploy a new version

Hangar pulls the image on every deployment, so redeploying a moving tag such as latest picks up the newest push.

To release automatically, call the service's deploy hook at the end of your CI job:

curl -fsS -X POST "$HANGAR_DEPLOY_HOOK"

Store the URL as a secret in your CI. You can also add it as a webhook in a registry that supports one; if the event names the image and tag, Hangar deploys only when they match the service's image. Deployments and rollbacks covers deploy hooks in full.

To pin exact releases, deploy a tag per version, such as ghcr.io/acme/api:1.4.2, and change the tag to release.

Port and variables

Set the container port your image listens on when you add a domain; see Domains and HTTPS. Environment variables are passed to the container at start, as with any service; see Environment variables.

Rollbacks

With rollbacks turned on, you can go back to the image an earlier deployment ran. For that to be the same build, deploy a tag per version: a moving tag such as latest points at whatever was pushed last.

Frequently asked questions

Can Hangar run an image from a private registry?
Yes. Enter the registry URL with a username and a password or access token when you set the image. Leave them empty for public images.
How do I redeploy when my CI pushes a new image?
Call the service's deploy hook from the CI job after the push, or add it as a webhook in your registry. Hangar pulls the image again and deploys it.

Deploy your app on Hangar

Connect a repository and it is live in minutes.

Start deploying