# Deploying with Docker Compose

Learn how to use Hatchbox to deploy an app with Docker Compose

Docker Compose can be useful for deploying custom app configurations to your servers with Hatchbox.

## Installing Docker

You&#39;ll first need to [install Docker](https://docs.docker.com/engine/install/ubuntu/) on your server as *root*. Then follow the [post-install steps for Docker](https://docs.docker.com/engine/install/linux-postinstall/).

```
$ curl -fsSL https://get.docker.com | sh
```

Add the deploy user to the Docker group:

```
$ sudo usermod -aG docker deploy
```

Configure Docker to start on boot:

```
 $ systemctl enable docker.service
 $ systemctl enable containerd.service
```

## Port Binding

Your web container needs to bind the Hatchbox app&#39;s assigned local port so HTTP requests can be forwarded from Caddy to your container.

```
    ports:
      - &quot;127.0.0.1:${PORT}:80&quot;
```

## Project Name

Compose also needs a name for your project so it knows which project to start and stop. You can specify this either in compose.yaml or using an environment variable

**compose.yml**

```
name: my-app
```

**ENV Variable**

```
COMPOSE_PROJECT_NAME=my-app
```

## Build Script

Your application will need a custom build script. This will run on all application servers:

```
docker compose down || true
```

**Note:** Docker Compose *won&#39;t* distribute containers across servers with roles in your Cluster. Each application server will run a copy of all the containers.

## Process

Add a Process assigned to the `web` role that runs Docker Compose.

```
docker compose up
```

This process tells Hatchbox to add a `reverse_proxy` to the Caddy configuration to forward requests to your Docker containers.

## Example

We&#39;ve put together a simple example to run Wordpress + MariaDB using Docker Compose on a Hatchbox server.

[https://github.com/hatchboxio/docker-compose-example](https://github.com/hatchboxio/docker-compose-example)
