> ## Documentation Index
> Fetch the complete documentation index at: https://taskdaemon.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Docker

# Docker Deployment

Running TaskDaemon with Docker and Docker Compose.

## Basic Docker Run

```bash theme={null}
docker run -d \
  -p 8080:8080 -p 50051:50051 \
  -v ./handlers.toml:/app/handlers.toml \
  -v /var/run/docker.sock:/var/run/docker.sock \
  mshelia/taskdaemon
```

### Required Volumes

| Volume                                      | Purpose                                       |
| ------------------------------------------- | --------------------------------------------- |
| `handlers.toml:/app/handlers.toml`          | Handler configuration                         |
| `/var/run/docker.sock:/var/run/docker.sock` | Docker socket for spawning handler containers |

### Ports

| Port  | Protocol | Description                      |
| ----- | -------- | -------------------------------- |
| 8080  | HTTP     | REST API, metrics, health checks |
| 50051 | gRPC     | gRPC API                         |

## Docker Compose

```yaml theme={null}
services:
  taskdaemon:
    image: mshelia/taskdaemon
    ports:
      - "8080:8080"
      - "50051:50051"
    volumes:
      - ./handlers.toml:/app/handlers.toml
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - DAEMON_WORKERS=4
      - DAEMON_LOG_LEVEL=info
```

## With Monitoring

```yaml theme={null}
services:
  taskdaemon:
    image: mshelia/taskdaemon
    ports:
      - "8080:8080"
    volumes:
      - ./handlers.toml:/app/handlers.toml
      - /var/run/docker.sock:/var/run/docker.sock

  prometheus:
    image: prom/prometheus:latest
    profiles: ["monitoring"]
    ports:
      - "9090:9090"
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
    depends_on:
      - taskdaemon

  grafana:
    image: grafana/grafana:latest
    profiles: ["monitoring"]
    ports:
      - "3001:3000"
    environment:
      - GF_SECURITY_ADMIN_PASSWORD=admin
    depends_on:
      - prometheus
```

Run with monitoring:

```bash theme={null}
docker compose --profile monitoring up
```

## Building Handler Images

Handler images must be available to the Docker daemon. Build them before starting TaskDaemon:

```yaml theme={null}
services:
  taskdaemon:
    image: mshelia/taskdaemon
    depends_on:
      - my-handler

  my-handler:
    build: ./handlers/my-handler
    image: my-handler:latest
    command: ["echo", "Handler built"]  # Just builds, doesn't run
```

## Health Checks

```yaml theme={null}
services:
  taskdaemon:
    image: mshelia/taskdaemon
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
      interval: 30s
      timeout: 10s
      retries: 3
```

## Resource Limits

```yaml theme={null}
services:
  taskdaemon:
    image: mshelia/taskdaemon
    deploy:
      resources:
        limits:
          cpus: '2'
          memory: 1G
```
