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

# Deploy: Docker

> Deploy agents to Docker containers using praisonai deploy

Build and deploy agents as Docker containers using `praisonai deploy run --type docker`.

## Quick Start - CLI

<Steps>
  <Step title="Install PraisonAI">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    pip install praisonai
    ```
  </Step>

  <Step title="Set API Key">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    export OPENAI_API_KEY="your-key"
    ```
  </Step>

  <Step title="Initialize Docker Config">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    praisonai deploy init --file agents.yaml --type docker
    ```
  </Step>

  <Step title="Deploy to Docker">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    praisonai deploy run --file agents.yaml --type docker
    ```

    **Expected Output:**

    ```
    🚀 Starting deployment...

    📦 Building Docker image: praisonai-app:latest
      • Base image: python:3.11-slim
      • Exposing ports: [8005]

    ✅ Deployment successful!
    🔗 URL: http://localhost:8005

    Metadata:
      • type: docker
      • image: praisonai-app:latest
      • container_id: abc123def456
    ```
  </Step>

  <Step title="Verify">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    docker ps | grep praisonai
    curl http://localhost:8005/health
    ```
  </Step>
</Steps>

## Quick Start - SDK

<Steps>
  <Step title="Create Deploy Script">
    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    from praisonai.deploy import Deploy, DeployConfig, DeployType
    from praisonai.deploy.models import DockerConfig

    config = DeployConfig(
        type=DeployType.DOCKER,
        docker=DockerConfig(
            image_name="praisonai-app",
            tag="latest",
            base_image="python:3.11-slim",
            expose=[8005],
            push=False
        )
    )

    deploy = Deploy(config, "agents.yaml")
    result = deploy.deploy()

    print(f"Image: {result.metadata.get('image')}")
    print(f"Container: {result.metadata.get('container_id')}")
    ```
  </Step>

  <Step title="Run">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    python deploy_docker.py
    ```
  </Step>
</Steps>

## agents.yaml with Docker Config

```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
framework: praisonai
topic: helpful assistant
roles:
  assistant:
    role: Assistant
    goal: Help users with their questions
    backstory: You are a helpful assistant
    tasks:
      help_task:
        description: Answer user questions
        expected_output: Helpful response

deploy:
  type: docker
  docker:
    image_name: "praisonai-app"
    tag: "latest"
    base_image: "python:3.11-slim"
    expose: [8005]
    push: false
    registry: null
```

## Docker Config Options

| Field        | Type       | Default            | Description            |
| ------------ | ---------- | ------------------ | ---------------------- |
| `image_name` | string     | `praisonai-app`    | Docker image name      |
| `tag`        | string     | `latest`           | Docker image tag       |
| `base_image` | string     | `python:3.11-slim` | Base Docker image      |
| `expose`     | list\[int] | `[8005]`           | Ports to expose        |
| `registry`   | string     | `null`             | Docker registry URL    |
| `push`       | bool       | `false`            | Push image to registry |
| `build_args` | dict       | `null`             | Docker build arguments |

## Push to Registry

```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
deploy:
  type: docker
  docker:
    image_name: "praisonai-app"
    tag: "v1.0.0"
    registry: "your-registry.com/your-org"
    push: true
```

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai deploy run --file agents.yaml --type docker
```

**Expected Output:**

```
🚀 Starting deployment...

📦 Building Docker image: your-registry.com/your-org/praisonai-app:v1.0.0
📤 Pushing to registry: your-registry.com/your-org

✅ Deployment successful!

Metadata:
  • image: your-registry.com/your-org/praisonai-app:v1.0.0
  • pushed: true
```

## Check Status

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai deploy status --file agents.yaml
```

## Stop Container

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai deploy destroy --file agents.yaml
```

**Expected Output:**

```
⚠️  Warning: This will destroy the deployment!
File: agents.yaml
Service: praisonai-app

Type 'yes' to confirm destruction: yes

🗑️ Destroying deployment...

✅ Deployment destroyed successfully

Deleted resources:
  • container: praisonai-app-abc123
  • image: praisonai-app:latest (local)
```

## Environment Variables

| Variable            | Required | Description       |
| ------------------- | -------- | ----------------- |
| `OPENAI_API_KEY`    | Yes\*    | OpenAI API key    |
| `ANTHROPIC_API_KEY` | No       | Anthropic API key |
| `GROQ_API_KEY`      | No       | Groq API key      |

\*Required if using OpenAI models.

## Troubleshooting

| Issue              | Fix                                                    |
| ------------------ | ------------------------------------------------------ |
| Docker not running | Start Docker daemon                                    |
| Build failed       | Check Dockerfile syntax, run `praisonai deploy doctor` |
| Push failed        | Check registry credentials                             |
| Port in use        | Change port in agents.yaml                             |
| Container exits    | Check logs: `docker logs <container>`                  |

<Accordion title="Manual Docker Commands (Optional)">
  These commands are for manual validation only. Use `praisonai deploy` for deployment.

  ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  # Build manually
  docker build -t praisonai-app:latest .

  # Run manually
  docker run -p 8005:8005 -e OPENAI_API_KEY=$OPENAI_API_KEY praisonai-app:latest

  # Check logs
  docker logs <container_id>

  # Stop
  docker stop <container_id>
  ```
</Accordion>

## Related

* [Deploy CLI Overview](./index) - All deploy commands
* [API Deploy](./api) - Deploy as local API server
* [AWS Deploy](./aws) - Deploy to AWS ECS/Fargate
* [GCP Deploy](./gcp) - Deploy to Google Cloud Run
