Deploy with Docker Compose
==========================

Deploy OpenPanel using Docker Compose on your own server

This guide will help you deploy OpenPanel using Docker Compose. This method gives you full control over your deployment and is perfect for self-hosting on a VPS or dedicated server.

[Prerequisites](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#prerequisites)

---------------------------------------------------------------------------------------------

*   A VPS or server (Docker and Node will be installed automatically if needed)
*   At least 2GB RAM (4GB+ recommended)
*   Domain name pointing to your server (optional but recommended)
*   Basic knowledge of command line

🙋‍♂️ This should work on any system. The setup script will install Docker and Node if they're not already installed.

[Quick Start](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#quick-start)

-----------------------------------------------------------------------------------------

### [Clone the Repository](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#clone-the-repository)

Clone the OpenPanel repository and navigate to the self-hosting directory:

    git clone -b self-hosting https://github.com/Openpanel-dev/openpanel.git
    cd openpanel/self-hosting

### [Run the Setup Script](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#run-the-setup-script)

The setup script will guide you through the configuration process. It will:

1.  Install Node.js (if you accept and it's not already installed)
2.  Install Docker (if you accept and it's not already installed)
3.  Run an interactive quiz/wizard that asks questions about your setup

> Setup takes 30s to 2 minutes depending on your VPS

    ./setup

The wizard will ask you questions about:

*   Your domain name
*   Database configuration
*   Email settings (optional)
*   AI integration (optional)
*   Registration settings

⚠️ If the `./setup` script fails to run, you can do it manually:

1.  Install Docker
2.  Install Node.js
3.  Install npm
4.  Run `npm run quiz` inside the self-hosting folder

### [Start the Services](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#start-the-services)

After the setup is complete, start all OpenPanel services:

    ./start

This will start all required services:

*   **op-db**: PostgreSQL database
*   **op-kv**: Redis cache
*   **op-ch**: ClickHouse analytics database
*   **op-api**: OpenPanel API server
*   **op-dashboard**: OpenPanel dashboard (frontend)
*   **op-worker**: Background worker for processing events

### [Verify Installation](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#verify-installation)

Check that all containers are running:

    docker compose ps

All services should show as "healthy" or "running". You can also check the logs:

    docker compose logs -f

Or use the provided logs script:

    ./logs

Once all services are healthy, you can access OpenPanel at your configured domain (or `http://your-server-ip` if you haven't configured a domain).

[Configuration](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#configuration)

---------------------------------------------------------------------------------------------

### [Environment Variables](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#environment-variables)

The setup wizard will configure most environment variables automatically. You can manually edit the `.env` file in the `self-hosting` directory if needed.

For a complete reference of all available environment variables, see the [Environment Variables documentation](https://openpanel.dev/docs/self-hosting/environment-variables)
.

If you change the `.env` file, you need to restart the services for the changes to take effect. Use `./stop` and `./start` or `docker compose restart`.

### [Using Custom Docker Images](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#using-custom-docker-images)

If you want to use specific image versions, edit the `docker-compose.yml` file and update the image tags:

    op-api:
      image: lindesvard/openpanel-api:2.0.0  # Specify version

### [Scaling Workers](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#scaling-workers)

To scale the worker service, set the `OP_WORKER_REPLICAS` environment variable:

    OP_WORKER_REPLICAS=3 docker compose up -d

Or edit the `docker-compose.yml` file:

    op-worker:
      deploy:
        replicas: 3

[Managing Your Deployment](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#managing-your-deployment)

-------------------------------------------------------------------------------------------------------------------

OpenPanel comes with several utility scripts to help manage your deployment. All scripts should be run from within the `self-hosting` directory.

### [Basic Operations](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#basic-operations)

    ./start    # Start all OpenPanel services
    ./stop     # Stop all OpenPanel services
    ./logs     # View real-time logs from all services

### [View Logs](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#view-logs)

View logs from all services:

    ./logs

Or using Docker Compose directly:

    docker compose logs -f

View logs from a specific service:

    docker compose logs -f op-api

### [Stop Services](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#stop-services)

Stop all services:

    ./stop

Or using Docker Compose:

    docker compose down

Stop services but keep volumes (data persists):

    docker compose stop

### [Restart Services](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#restart-services)

Restart all services:

    ./stop && ./start

Or using Docker Compose:

    docker compose restart

Restart a specific service:

    docker compose restart op-api

### [Rebuild Services](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#rebuild-services)

Rebuild and restart a specific service:

    ./rebuild op-dashboard

### [Update OpenPanel](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#update-openpanel)

To update to the latest version, use the update script:

    ./update

This script will:

1.  Pull the latest changes from the repository
2.  Pull the latest Docker images
3.  Restart all services

If you don't have the `./update` script, you can manually update:

    git pull
    docker compose pull
    docker compose up -d

Always backup your data before updating. The database migrations will run automatically when the API container starts. Also read any changes in the [changelog](https://openpanel.dev/docs/self-hosting/changelog)
 and apply them to your instance.

### [Backup and Restore](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#backup-and-restore)

#### [Backup](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#backup)

Backup your PostgreSQL database:

    docker compose exec op-db pg_dump -U postgres postgres > backup.sql

Backup volumes:

    docker run --rm -v openpanel_op-db-data:/data -v $(pwd):/backup alpine tar czf /backup/db-backup.tar.gz /data

#### [Restore](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#restore)

Restore PostgreSQL database:

    docker compose exec -T op-db psql -U postgres postgres < backup.sql

[Troubleshooting](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#troubleshooting)

-------------------------------------------------------------------------------------------------

### [Services Won't Start](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#services-wont-start)

1.  Check Docker and Docker Compose versions:
    
        docker --version
        docker compose version
    
2.  Check available disk space:
    
        df -h
    
3.  Check logs for errors:
    
        docker compose logs
    

### [Database Connection Issues](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#database-connection-issues)

If services can't connect to the database:

1.  Verify the database is healthy:
    
        docker compose ps op-db
    
2.  Check database logs:
    
        docker compose logs op-db
    
3.  Verify `DATABASE_URL` in your `.env` file matches the service name `op-db`
    

### [Port Conflicts](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#port-conflicts)

If ports 80 or 443 are already in use, you can:

1.  Change the ports in `docker-compose.yml`:
    
        ports:
          - "8080:80"
          - "8443:443"
    
2.  Or stop the conflicting service
    

### [Health Check Failures](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#health-check-failures)

If health checks are failing:

1.  Check if services are actually running:
    
        docker compose ps
    
2.  Increase health check timeout in `docker-compose.yml`:
    
        healthcheck:
          interval: 30s
          timeout: 10s
          retries: 10
    

[Using Your Own Reverse Proxy](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#using-your-own-reverse-proxy)

---------------------------------------------------------------------------------------------------------------------------

If you want to use NGINX, Traefik, or another reverse proxy instead of the bundled Caddy — or put a TLS terminator upstream of Caddy — see the dedicated [Reverse proxy setup](https://openpanel.dev/docs/self-hosting/reverse-proxy)
 guide. It covers the working NGINX config, the `Connection: upgrade` SSR-break gotcha, and the WebSocket upgrade headers required for the Realtime view.

[Next Steps](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#next-steps)

---------------------------------------------------------------------------------------

*   [Configure email settings](https://openpanel.dev/docs/self-hosting/self-hosting#e-mail)
     for password resets and invitations
*   [Set up AI integration](https://openpanel.dev/docs/self-hosting/self-hosting#ai-integration)
     for the analytics assistant
*   [Configure SDK](https://openpanel.dev/docs/self-hosting/self-hosting#always-use-correct-api-url)
     to track events from your applications

[Get started\
\
Previous Page](https://openpanel.dev/docs/self-hosting/self-hosting)
[Deploy with Coolify\
\
Next Page](https://openpanel.dev/docs/self-hosting/deploy-coolify)

### On this page

[Prerequisites](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#prerequisites)
[Quick Start](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#quick-start)
[Clone the Repository](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#clone-the-repository)
[Run the Setup Script](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#run-the-setup-script)
[Start the Services](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#start-the-services)
[Verify Installation](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#verify-installation)
[Configuration](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#configuration)
[Environment Variables](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#environment-variables)
[Using Custom Docker Images](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#using-custom-docker-images)
[Scaling Workers](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#scaling-workers)
[Managing Your Deployment](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#managing-your-deployment)
[Basic Operations](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#basic-operations)
[View Logs](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#view-logs)
[Stop Services](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#stop-services)
[Restart Services](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#restart-services)
[Rebuild Services](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#rebuild-services)
[Update OpenPanel](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#update-openpanel)
[Backup and Restore](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#backup-and-restore)
[Backup](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#backup)
[Restore](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#restore)
[Troubleshooting](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#troubleshooting)
[Services Won't Start](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#services-wont-start)
[Database Connection Issues](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#database-connection-issues)
[Port Conflicts](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#port-conflicts)
[Health Check Failures](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#health-check-failures)
[Using Your Own Reverse Proxy](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#using-your-own-reverse-proxy)
[Next Steps](https://openpanel.dev/docs/self-hosting/deploy-docker-compose#next-steps)