# Custom Docker Compose

> Deploy a custom Docker Compose stack on OnePloy with generated URLs, passwords and per-service domains using SERVICE_URL and SERVICE_PASSWORD.

Source: https://oneploy.dev/docs/services/custom-docker-compose/  
Updated: 2026-11-02

To run a stack that is not in the template catalogue, deploy your own Docker Compose file. Add a **Docker Compose** resource and paste the file, or use the **Docker Compose** build pack to read it from a Git repository. OnePloy deploys every service in the file and can generate URLs, usernames and passwords for you.

## Two ways to deploy Compose

| Option | Where the Compose file lives | Use it when |
| --- | --- | --- |
| Docker Compose resource | Pasted into OnePloy | You want a quick stack without a repository. |
| Docker Compose build pack | In your Git repository | The Compose file builds your own code and should deploy on push. |

## How do I deploy a Compose file?

1. Open a project environment and choose **Add resource**.
2. Select **Docker Compose** and paste your file.
3. Save. OnePloy parses the file and lists each service.
4. Set a domain for every service that serves HTTP.
5. Deploy.

## How do I get generated URLs and passwords?

Reference special variables in the Compose file. OnePloy fills them in when the resource is created and keeps them stable afterwards:

```yaml
services:
  app:
    image: ghcr.io/example/app:1.4.0
    environment:
      - SERVICE_URL_APP_3000
      - APP_URL=${SERVICE_URL_APP}
      - DB_USER=${SERVICE_USER_POSTGRES}
      - DB_PASSWORD=${SERVICE_PASSWORD_POSTGRES}
      - DB_HOST=postgres
    depends_on:
      - postgres
  postgres:
    image: postgres:16-alpine
    environment:
      - POSTGRES_USER=${SERVICE_USER_POSTGRES}
      - POSTGRES_PASSWORD=${SERVICE_PASSWORD_POSTGRES}
      - POSTGRES_DB=app
    volumes:
      - pg-data:/var/lib/postgresql/data
volumes:
  pg-data:
```

In this example:

- `SERVICE_URL_APP_3000` creates a URL for the `app` service and routes it to container port 3000.
- `${SERVICE_URL_APP}` passes that URL to the application.
- `SERVICE_USER_POSTGRES` and `SERVICE_PASSWORD_POSTGRES` generate one username and password that both containers share.

The full list of prefixes is in [Environment variables](https://oneploy.dev/docs/applications/environment-variables/).

## Default values

Use standard Compose default syntax for values the user may override later:

```yaml
environment:
  - TZ=${TZ:-UTC}
```

The variable appears in the resource’s environment variables, pre-filled with the default.

## Networking between services

All services in the same Compose file share a network and reach each other by service name, such as `postgres` in the example above. You do not need to publish database ports.

## Volumes

Named volumes and bind mounts declared in the file become persistent storage that survives redeployments. You can back them up on a schedule from the service’s storage backups page. See [Persistent storage](https://oneploy.dev/docs/applications/persistent-storage/).

> **Tip:** Pin image tags (for example `postgres:16-alpine`) instead of `latest`, so a redeploy never pulls an unexpected major version.
