# Docker Compose Deployment Docker Compose is the recommended deployment method for production environments. It provides better service management, easier configuration, and simplified upgrades. ## Prerequisites ### Install Docker If you haven't installed Docker yet, please follow the official installation guide: **Ubuntu/Debian:** ```bash # Update package index sudo apt-get update # Install required packages sudo apt-get install -y ca-certificates curl gnupg lsb-release # Add Docker's official GPG key sudo mkdir -p /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg # Set up the repository echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null # Install Docker Engine sudo apt-get update sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin ``` **CentOS/RHEL:** ```bash # Install yum-utils sudo yum install -y yum-utils # Add Docker repository sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo # Install Docker Engine sudo yum install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin # Start Docker service sudo systemctl start docker sudo systemctl enable docker ``` ### Verify Installation ```bash # Check Docker version docker --version # Check Docker Compose version docker compose version # Test Docker installation sudo docker run hello-world ``` ## Deployment Steps ### Step 1: Create Project Directory ```bash # Create project directory mkdir -p ~/ppanel cd ~/ppanel ``` ### Step 2: Create docker-compose.yml Create a `docker-compose.yml` file with the following content: ```yaml version: '3.8' services: ppanel: image: ppanel/ppanel:latest container_name: ppanel ports: - "8080:8080" volumes: - ./ppanel-config:/app/etc:ro - ppanel-data:/app/data restart: unless-stopped environment: - TZ=UTC healthcheck: test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8080/health"] interval: 30s timeout: 10s retries: 3 start_period: 40s volumes: ppanel-data: driver: local ``` **Configuration Explanation:** - **image**: Docker image to use (latest or specific version like `v0.1.2`) - **ports**: Map container port 8080 to host port 8080 - **volumes**: - `./ppanel-config:/app/etc:ro` - Configuration directory (read-only) - `ppanel-data:/app/data` - Persistent data storage - **restart**: Auto-restart policy - **environment**: Set timezone (change to your timezone like `Asia/Shanghai`) - **healthcheck**: Monitor service health ### Step 3: Prepare Configuration ```bash # Create configuration directory mkdir -p ppanel-config # Create configuration file cat > ppanel-config/ppanel.yaml < Container port 8080 ``` ### Multiple Instances To run multiple instances, create separate directories: ```bash # Instance 1 mkdir ~/ppanel-1 cd ~/ppanel-1 # Create docker-compose.yml with port 8081 # Instance 2 mkdir ~/ppanel-2 cd ~/ppanel-2 # Create docker-compose.yml with port 8082 ``` ### Resource Limits Add resource limits to prevent overconsumption: ```yaml services: ppanel: # ... other config ... deploy: resources: limits: cpus: '2' memory: 2G reservations: cpus: '0.5' memory: 512M ``` ### Custom Network Create a custom network for better isolation: ```yaml version: '3.8' services: ppanel: # ... other config ... networks: - ppanel-net networks: ppanel-net: driver: bridge ``` ## Troubleshooting ### Container Fails to Start ```bash # Check logs for errors docker compose logs ppanel # Check container status docker compose ps # Verify configuration docker compose config ``` ### Port Already in Use ```bash # Check what's using the port sudo lsof -i :8080 # Change port in docker-compose.yml # ports: # - "8081:8080" ``` ### Permission Issues ```bash # Fix configuration directory permissions sudo chown -R $USER:$USER ppanel-config/ # Make sure files are readable chmod 644 ppanel-config/ppanel.yaml ``` ### Cannot Access from Outside 1. **Check firewall rules:** ```bash # Ubuntu/Debian sudo ufw allow 8080 # CentOS/RHEL sudo firewall-cmd --add-port=8080/tcp --permanent sudo firewall-cmd --reload ``` 2. **Verify service is listening:** ```bash docker compose ps netstat -tlnp | grep 8080 ``` ## Next Steps - [Configuration Guide](/guide/configuration) - Detailed configuration options - [Admin Dashboard](/admin/dashboard) - Start managing your panel - [API Reference](/api/reference) - API integration guide ## Need Help? If you encounter any issues: 1. Check the [Troubleshooting](#troubleshooting) section above 2. Review [Docker Compose logs](#view-logs) 3. Search [GitHub Issues](https://github.com/perfect-panel/ppanel/issues) 4. Create a new issue with detailed system information and logs