Docker Compose

Deploy a docker-compose.yml on Hangar from your repository or pasted in, as Docker Compose on one node or as a Swarm stack across the region.

Updated

If your app is already described in a docker-compose.yml, you can deploy it as it is. A compose service on Hangar runs the whole file, with each of its services, as one unit in your project.

For a single app, a regular service is simpler: it gets builds, rollbacks and preview deployments. Compose is the right fit when the file is the source of truth, for example software that ships with a compose file.

Create a compose service

In a project, choose New → Compose stack and pick how it runs:

ModeRunsBuildsUse it for
Docker Composedocker compose up on one nodebuild: and depends_on work, like on your machinemost compose files
Swarm stackdocker stack deploy across the region's nodesimages must be prebuilt; build: is ignoredservices you want to replicate

Then set where the file comes from:

  • A repository, from a connected Git provider or any public Git URL, with the path to the compose file. Pushes deploy it again, like any other service.
  • Raw, by pasting the file into the editor. Good for a quick start or a file that does not live in a repository.

Domains

A compose file can have many services, so a domain names the one it points to. In the compose service's networking settings, add a domain, choose the service in the file and the port it listens on. HTTPS certificates are issued and renewed as for any other domain; see Domains and HTTPS.

You do not need ports: in the file for traffic that comes through a domain.

Variables

Variables set on the compose service are available to the file. Reference them with ${NAME} in the compose file, as you would with a .env next to it. Project and environment variables can be referenced too; see Environment variables.

Logs, metrics and jobs

Logs, metrics and traces are collected for every container of the compose service; see Observability. Cron jobs can run a command in any service of the file.

What you pay for

A compose service is metered like any other: the CPU and memory its containers use, the storage of its volumes and its egress. See Pricing.

Frequently asked questions

Can I deploy an existing docker-compose.yml on Hangar?
Yes. Add a compose stack, point it at the repository that holds the file or paste the file in, and deploy. Each service in the file can get its own domain.
What is the difference between Docker Compose and Swarm stack on Hangar?
Docker Compose runs docker compose up on a single node and supports build and depends_on, like on your machine. Swarm stack runs docker stack deploy so services can replicate across the region's nodes, but images must be prebuilt and build is ignored.

Deploy your app on Hangar

Connect a repository and it is live in minutes.

Start deploying