# Docker

> Run Trident as a Docker container from the official Trident Container Registry.

Run Trident as a Docker container from the official Trident Container Registry.

## Pull the Image

```bash
docker pull docker.trident-cache.com/trident:latest
```

For a specific version:

```bash
docker pull docker.trident-cache.com/trident:1.0.0
```

## Run

Basic usage with default configuration:

```bash
docker run -d \
  --name trident \
  -p 8120:8120 \
  docker.trident-cache.com/trident:latest
```

With a custom configuration file:

```bash
docker run -d \
  --name trident \
  -p 8120:8120 \
  -v /path/to/config.toml:/etc/trident/config.toml:ro \
  docker.trident-cache.com/trident:latest
```

With a license key:

```bash
docker run -d \
  --name trident \
  -p 8120:8120 \
  -v /path/to/config.toml:/etc/trident/config.toml:ro \
  -v /path/to/license.key:/etc/trident/license.key:ro \
  docker.trident-cache.com/trident:latest
```

## Docker Compose

```yaml
services:
  trident:
    image: docker.trident-cache.com/trident:latest
    ports:
      - "8120:8120"
    volumes:
      - ./config.toml:/etc/trident/config.toml:ro
      - ./license.key:/etc/trident/license.key:ro
    restart: unless-stopped
```

## Exposed Ports

| Port   | Description   |
|--------|---------------|
| `8120` | HTTP listener |

<Admonition type="tip" title="Customizing Ports">
The ports shown above are defaults from the config file. You can change them in your `config.toml` and update the Docker port mappings accordingly. For example, to also expose the admin API and metrics, map additional ports.
</Admonition>

## Update to Latest Version

Pull the latest image and recreate the container:

```bash
# Pull the newest image
docker pull docker.trident-cache.com/trident:latest

# Stop and remove the old container
docker stop trident && docker rm trident

# Start with the new image
docker run -d \
  --name trident \
  -p 8120:8120 \
  -v /path/to/config.toml:/etc/trident/config.toml:ro \
  docker.trident-cache.com/trident:latest
```

With Docker Compose:

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

<Admonition type="tip" title="Pin to a specific version">
For production, pin to a version tag instead of `latest` to avoid unexpected updates:

```yaml
image: docker.trident-cache.com/trident:v1.0.10
```

Then update explicitly:

```yaml
image: docker.trident-cache.com/trident:v1.0.11
```
</Admonition>

### Check Current Version

```bash
# Running container
docker exec trident trident --version

# Available tags
curl -s https://docker.trident-cache.com/v2/trident/tags/list | python3 -m json.tool
```

### Zero-Downtime Update (Docker Compose)

If you need zero-downtime updates, use a rolling restart with a load balancer or run two instances:

```bash
# Scale up (start new container alongside old one)
docker compose up -d --scale trident=2 --no-recreate

# Wait for new container to be healthy
sleep 5

# Remove old container
docker compose up -d --scale trident=1
```

## Verify

```bash
docker exec trident trident --version
docker exec trident trident-cli --version
```

## Available Images

| Image | Description |
|-------|-------------|
| `docker.trident-cache.com/trident` | Trident HTTP Cache Proxy |
| `docker.trident-cache.com/prism` | Trident PRISM Dynamic Rendering |
| `docker.trident-cache.com/trident-admin` | Trident Admin Dashboard |

## Next Steps

- [Configuration](https://docs.qoliber.com/docs/trident/configuration) -- customize your `config.toml`
