EN · $ USD
Developer and Application Servers

How to Deploy a Docker Compose Project on Coolify

8 min read Updated: Sunucu Atlas technical team

In short

To deploy a Docker Compose project on Coolify, connect your repository and pick Docker Compose as the build pack. When adapting the file, use expose instead of ports, keep database data in named volumes, move passwords into ${VARIABLE} environment variables, and give each web service a domain in the Domains field in the form https://domain.com:3000. Services reach each other on the internal network by service name.

In this guide
  1. How does Coolify interpret a Docker Compose file?
  2. Starting point: a compose file that works locally
  3. Adapting the compose file for Coolify
  4. Deploying on Coolify step by step
  5. Assigning a domain per service
  6. Internal network: how do services reach each other?
  7. Volumes and backups
  8. Common problems
  9. How many resources do you need?
  10. Next step: start with a Coolify-ready server

To deploy a Docker Compose project on Coolify, you connect your repository to Coolify and pick Docker Compose as the build pack; Coolify reads your file and runs each service as its own container. The real work is adapting the file for a server: hand the domain to Coolify instead of publishing ports to the internet, keep data in named volumes, take passwords out of the file, and make sure services talk to each other by service name. In this guide we take a typical web + API + PostgreSQL + Redis stack from start to production.

How does Coolify interpret a Docker Compose file?

Coolify is an open-source, self-hosted PaaS (Platform as a Service) panel that you install on your own server. It deploys apps from a Git repository or a prebuilt image, puts a Traefik-based reverse proxy in front of them and gets SSL certificates from Let's Encrypt automatically. If Coolify is new to you, start with What is Coolify and why it is seen as a Vercel/Heroku alternative.

With the Docker Compose build pack, your file shows up as a single resource, but every service inside it is managed separately:

  • Service names act as internal DNS: A unique ID is appended to container names, but services in the same compose file can still reach each other by service names such as db and redis.
  • A separate network per resource: Coolify creates a dedicated Docker network for the resource and attaches the proxy to it; outside traffic is routed only to the services you give a domain.
  • Volume names get a prefix: Named volumes are prefixed with the resource ID, so pgdata volumes in two different projects never collide.
  • Variables move into the UI: Every variable written as ${DEGISKEN} in the file becomes editable in the resource's Environment Variables tab.

Starting point: a compose file that works locally

A typical file used in development looks like this:

services:
  web:
    build: ./web
    ports:
      - "3000:3000"
  api:
    build: ./api
    ports:
      - "8080:8080"
    environment:
      DATABASE_URL: postgres://app:gizli@db:5432/app
  db:
    image: postgres:16
    ports:
      - "5432:5432"
    volumes:
      - ./pgdata:/var/lib/postgresql/data
  redis:
    image: redis:7

This file runs fine locally, but on a server it carries three risks: the PostgreSQL port is exposed to the internet, the password sits in plain text in your Git history, and the relative ./pgdata bind mount ends up in a server folder you are not tracking.

Adapting the compose file for Coolify

1. Use expose instead of ports

On Coolify, Traefik receives outside traffic and forwards it to the container over the internal network. So the web and API services do not need a ports line; declaring the port they listen on with expose is enough. Do not define any port for the database or Redis. Every port published with ports opens on the server's public IP, and because Docker writes its own iptables rules, it can bypass firewall rules such as UFW.

2. Move persistent data to named volumes

Files inside a container are wiped every time it is recreated; volumes are the only thing that survives a redeploy. Mount the database and Redis directories to named volumes and declare those volumes at the bottom of the file. Coolify lists them under Persistent Storage and keeps them across deploys.

3. Move passwords into environment variables

Instead of writing the password into the file, use ${POSTGRES_PASSWORD:?}. The trailing :? makes the variable required; the deploy will not start until a value is set. To provide a default value, use the ${DEGISKEN:-varsayilan} syntax.

4. Add a health check and startup order

If the API starts before the database is ready, it crashes on its first connection attempt. Use a healthcheck to confirm PostgreSQL is actually accepting connections, and tie the API to that state with depends_on.

The adapted file looks like this:

services:
  web:
    build: ./web
    expose:
      - "3000"
    environment:
      NEXT_PUBLIC_API_URL: ${API_URL}
    depends_on:
      - api
  api:
    build: ./api
    expose:
      - "8080"
    environment:
      DATABASE_URL: postgres://app:${POSTGRES_PASSWORD:?}@db:5432/app
      REDIS_URL: redis://redis:6379
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_started
  db:
    image: postgres:16
    environment:
      POSTGRES_USER: app
      POSTGRES_DB: app
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?}
    volumes:
      - pgdata:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U app -d app"]
      interval: 10s
      timeout: 5s
      retries: 5
  redis:
    image: redis:7
    command: ["redis-server", "--appendonly", "yes"]
    volumes:
      - redisdata:/data

volumes:
  pgdata:
  redisdata:

If your password contains characters such as @, : or /, it must be URL-encoded in the connection string; to avoid trouble, pick a long password made of letters and digits.

Deploying on Coolify step by step

  1. In the Coolify panel, create a project and an environment (for example production), then add a new resource with + New.
  2. Choose the repository source: a public repository, a GitHub App, or a deploy key for a private repository. For GitHub integration details, see Setting up automatic deploys from GitHub with Coolify.
  3. Pick Docker Compose as the build pack. Enter the project's root folder in Base Directory and the file path in Docker Compose Location (the default is /docker-compose.yaml; if your file uses the .yml extension, fix the path).
  4. Once Coolify reads the file, it lists the services. Enter values for POSTGRES_PASSWORD and API_URL in the Environment Variables tab.
  5. Assign domains to the web and API services (see the next section).
  6. Click Deploy and follow the build logs in the Deployments tab.

Assigning a domain per service

In a compose resource, every service has its own Domains field. You enter the domain in this format:

ServiceDomains fieldNotes
webhttps://ornek.com:3000Visitors come in on 443; Traefik forwards to port 3000 in the container
apihttps://api.ornek.com:8080Separate subdomain, 8080 inside the container
dbemptyReachable only from the internal network
redisemptyReachable only from the internal network

The trailing :3000 is not a port opened to the outside world; it tells Traefik which container port to forward the request to. Visitors always use the standard 80/443 ports. When you prefix the address with https://, Coolify requests the certificate automatically; for that, the domain's A record must point to the server IP before you deploy.

Alternatively, you can define the domain inside the file: when you add one of Coolify's "magic" environment variables such as SERVICE_FQDN_API_8080 to a service, the panel fills in that service's domain field automatically. Variables from the same family with the SERVICE_PASSWORD_ prefix can be used to generate random passwords.

Internal network: how do services reach each other?

Services in the same compose file find each other by service name: the API connects to the database at db:5432 and to Redis at redis:6379. The two most common mistakes here are:

  • Code running in the browser cannot see internal addresses. Requests the frontend makes to the API from the user's browser must go to https://api.ornek.com, not to http://api:8080. Code that runs on the server (SSR) can use the internal address.
  • Do not use container_name or localhost. A fixed container_name can clash with Coolify's naming, and localhost inside a container refers only to that container itself.

If you need to connect to a Coolify resource outside the compose file, for example a separate database you created with one click in the panel, turn on Connect to Predefined Network in the resource settings. In that case you reach the target not by service name but by the full container name or internal connection URL that Coolify shows.

Volumes and backups

A named volume survives deploys, but it is not a backup against server failure. For critical data you have two options:

  • Run the database as a separate resource: Instead of keeping PostgreSQL inside the compose file, create it as a separate resource with Coolify's one-click database feature and set up scheduled backups.
  • Scheduled task: For a database that stays inside the compose file, define a pg_dump command that runs in the db service under Coolify's Scheduled Tasks, write the output to a separate volume and copy it off the server.

Common problems

  • Relative bind mounts: Definitions like ./config:/app/config are resolved relative to Coolify's resource folder on the server. Copying config files into the image or using a named volume is more predictable.
  • Build-time variables: Variables baked into the code at build time, such as NEXT_PUBLIC_, stay empty if they are only provided at runtime; mark them as available at build time in Coolify.
  • Wrong port: The port in the Domains field must match the port the app listens on inside the container; otherwise you get a 502. For this and similar errors, see the Coolify deploy errors guide.

How many resources do you need?

A four-service stack runs on modest resources at runtime; the real load comes from building images on the same server. As a rough guide, 2 CPUs and 4 GB of RAM is a good starting point for a single web + API + PostgreSQL + Redis project. If you build several projects on the same server or your database is large, 4 CPUs and 8 GB of RAM give you more headroom.

Next step: start with a Coolify-ready server

If you would rather not install Coolify from scratch, set up Docker and configure the proxy yourself, Sunucu Atlas AI Hosting plans with the Coolify panel preinstalled are built for exactly this workflow: deploys from GitHub and Docker, automatic SSL certificates, one-click databases and root access, on a server in Istanbul. For a single compose project, SA-AI-1 with 2 CPUs, 4 GB of RAM and a 40 GB NVMe disk is enough; if you will build several projects on the same server, choose SA-AI-2 with 4 CPUs and 8 GB of RAM. If you get stuck, you can open a support ticket.

Frequently asked questions

Should the file on Coolify be docker-compose.yml or docker-compose.yaml?

Both work. Coolify looks for /docker-compose.yaml by default; if your file uses the .yml extension, just correct the path in the Docker Compose Location field.

Do I need to open ports for the services in my compose file?

No. For web services, expose is enough, since traffic arrives through Traefik on your domain. Do not define any ports for services like the database and Redis, so they are reachable only from the internal network.

Will my database data be deleted when I redeploy?

Not if you keep the data in a named volume; Coolify preserves volumes across deploys. Data written to container directories that are not mounted to a volume is lost every time the container is recreated.

Can I give each service in a compose project its own domain?

Yes. Every service has its own Domains field; for example, you can enter https://ornek.com:3000 for the web service and https://api.ornek.com:8080 for the API service. The trailing port is the port the app listens on inside the container.

Why can't my frontend connect to http://api:8080?

Service names resolve only inside the internal Docker network. Code running in the user's browser is outside that network, so it must use the API's public domain.

For this guide

Recommended plans

AI Hosting plans come with the Coolify panel preinstalled, automatic SSL and root access, so you can put your multi-service compose project live without wrestling with setup.

SA-AI-1

Coolify
Recommended

4 GB RAM

$2.75/mo

+VAT

  • Processor2 CPU
  • Disk40 GB NVMe
  • LocationIstanbul
  • 1G Port
  • Coolify Panel Preinstalled
  • Deploy with GitHub and Docker
  • Automatic SSL Certificate

SA-AI-2

Coolify

8 GB RAM

$4.32/mo

+VAT

  • Processor4 CPU
  • Disk80 GB NVMe
  • LocationIstanbul
  • 1G Port
  • Coolify Panel Preinstalled
  • Deploy with GitHub and Docker
  • Automatic SSL Certificate

SA-AI-3

Coolify

12 GB RAM

$6.29/mo

+VAT

  • Processor6 CPU
  • Disk120 GB NVMe
  • LocationIstanbul
  • 1G Port
  • Coolify Panel Preinstalled
  • Deploy with GitHub and Docker
  • Automatic SSL Certificate

AI Hosting — tüm paketler

Need help with setup?

Send questions about your service in a support ticket, and our technical team will walk you through it step by step.