# Run Mirli in Docker

This guide runs the Mirli server and web UI in a container, without the
desktop app, on a home server, a NAS or a GPU machine. The image already
contains the audio.cpp runtime.

> [!WARNING]
> The server has no login unless you set a token. These steps publish the
> port on `127.0.0.1` only. To reach it from other machines, follow
> [Reach Mirli from another machine](https://mirli.app/docs/install-remote/index.md) first.

## Before you begin

- Install Docker with Compose.
- Get `docker-compose.yml` from the repository, or clone the repository.
- For an NVIDIA GPU, install the
  [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html)
  on the host.

Prebuilt images are amd64 only. On arm64, follow
[Build the image yourself](#build-the-image-yourself).

## Start the container

1. In the folder with `docker-compose.yml`, start Mirli:

   ```bash
   docker compose up -d
   ```

   Compose pulls `ghcr.io/hamsanders/soundbox:latest` and starts it.

2. Open `http://localhost:17494`.
3. Download a model from the **Models** page, or from the command line:

   ```bash
   docker compose exec soundbox soundbox pull audiocpp-stable-audio-3-sfx
   ```

The container keeps its data in two volumes, described in the
[Docker image reference](https://mirli.app/docs/install-docker-image/index.md#volumes).

## Start the container with an NVIDIA GPU

1. Check that a container can see your GPU:

   ```bash
   docker run --rm --gpus all ubuntu nvidia-smi
   ```

   The output lists your GPU.

2. Start Mirli with the CUDA override file:

   ```bash
   docker compose -f docker-compose.yml -f docker-compose.cuda.yml up -d
   ```

   Compose pulls `ghcr.io/hamsanders/soundbox:cuda`.

For AMD and Intel GPUs, build a Vulkan image; see the
[build arguments](https://mirli.app/docs/install-docker-image/index.md#build-arguments).

## Run without Compose

To start the CPU image with `docker run`:

```bash
docker run -d --name soundbox -p 127.0.0.1:17494:17494 \
  -v soundbox-data:/data -v soundbox-models:/data/models \
  ghcr.io/hamsanders/soundbox:latest
```

For the CUDA image, add `--gpus all` after `-d` and use the `:cuda` tag.

## Build the image yourself

To run your own changes, or on arm64, build from a clone of the repository:

```bash title="CPU"
docker compose -f docker-compose.yml -f docker-compose.build.yml up -d --build
```

```bash title="NVIDIA"
docker compose -f docker-compose.yml -f docker-compose.cuda.yml \
  -f docker-compose.build.yml -f docker-compose.build-cuda.yml up -d --build
```

## Run without local models

For a machine that generates only through
[custom endpoints](https://mirli.app/docs/endpoints/index.md), build the slim image. It has no audio.cpp,
needs no GPU and is a fraction of the size:

```bash
docker build -f Dockerfile.slim -t mirli-slim .
docker run -d -p 127.0.0.1:17494:17494 -v mirli-data:/data mirli-slim
```

The **Models** page then offers no models to download.

## What's next

- [Docker image reference](https://mirli.app/docs/install-docker-image/index.md)
- [Reach Mirli from another machine](https://mirli.app/docs/install-remote/index.md)
- [Send generation to another server](https://mirli.app/docs/endpoints/index.md)
