Docker Containers in CloudPanel: Advanced Deployment
Run Docker containers in CloudPanel. Multi-container apps, Docker Compose, persistent data, logging, resource monitoring, production best practices.
On this page
Docker containers are lightweight, portable units that package applications with all dependencies. CloudPanel integrates Docker for advanced scenarios: run multiple services (web app + database + cache), isolate applications, simplify deployment, and scale applications. Perfect for microservices, complex architectures, or teams running many applications.
Docker Overview
Docker solves common problems:
- Dependency conflicts: "Works on my machine" but not production → Docker fixes this
- Multiple apps on one server: Run Node.js, Python, Go apps simultaneously without conflicts
- Easy deployment: Deploy the exact same container everywhere
- Resource isolation: Containers can't interfere with each other
- Quick start/stop: Containers start in 1-5 seconds
Docker in CloudPanel
CloudPanel integrates Docker via:
- Docker daemon: Core Docker service running in background
- Docker CLI: Command-line tools for managing containers
- Docker Compose: Manage multi-container applications
- Reverse proxy: Nginx routes external traffic to containers
- SSL/TLS: Let's Encrypt certificates automatically issued
CloudPanel advantages over manual Docker:
- No SSH CLI needed (web interface available)
- Automatic SSL certificate management
- Integrated backup and monitoring
- Resource usage tracking
Install Docker
Check if Docker is installed:
docker --version
docker-compose --version
If not installed, install via SSH:
# Debian/Ubuntu (CloudPanel default)
apt update
apt install docker.io docker-compose
systemctl enable docker
systemctl start docker
# Add www-data user to docker group (CloudPanel web user)
usermod -aG docker www-data
Run First Container
Simple test: Run Nginx
docker run -d \
-p 8080:80 \
--name webserver \
nginx:latest
# Access at http://yourip:8080
More practical: Run MySQL database**
docker run -d \
-p 3306:3306 \
-e MYSQL_ROOT_PASSWORD=secure_pass123 \
-v mysql_data:/var/lib/mysql \
--name database \
mysql:8.0
# Now other containers can connect to this database
View running containers:
docker ps # Running containers
docker ps -a # All containers (stopped too)
docker logs database # View container output/errors
Docker Compose (Multi-Container)
Docker Compose runs multiple containers from one yaml file:
Example docker-compose.yml (web app + database):
version: '3.8'
services:
web:
image: node:18
ports:
- "3000:3000"
volumes:
- ./app:/app
working_dir: /app
command: npm start
depends_on:
- db
db:
image: postgres:14
environment:
POSTGRES_DB: appdb
POSTGRES_PASSWORD: secure_pass
volumes:
- db_data:/var/lib/postgresql/data
volumes:
db_data:
Run all containers:
docker-compose up -d # Start all services
docker-compose logs # View logs from all containers
docker-compose down # Stop all services
Persistent Data & Volumes
Container data is lost when container stops. Use volumes for persistence:
- Named volumes: Docker-managed storage (recommended)
- Bind mounts: Mount host directory into container
Named volume example:**
# Create volume
docker volume create mydata
# Use in container
docker run -d \
-v mydata:/data \
myapp
# Data persists even if container deleted
Backup volume:
docker run --rm \
-v mydata:/data \
-v /backup:/backup \
alpine tar czf /backup/mydata.tar.gz /data
Monitor Containers
Real-time monitoring:
docker stats # CPU, memory, network usage
docker inspect containername # Detailed configuration
docker logs -f containername # Follow logs in real-time
Check container health:
docker ps # STATUS column shows health
# Examples: Up 2 days, Exited (0), Unhealthy
Production Best Practices
- Resource limits: Prevent runaway containers
- Health checks: Automatically restart failed containers
- Persistent backups: Regular volume backups
- Logging: Send logs to centralized system
- Monitoring: CPU, memory, disk alerts
- Network isolation: Containers on private network
Resource-limited container:
docker run -d \
--memory=1g \
--cpus=1.5 \
--restart=always \
--health-cmd="curl -f http://localhost/ || exit 1" \
--health-interval=10s \
myapp
Auto-restart on failure:**
--restart=always # Always restart
--restart=unless-stopped # Unless explicitly stopped
--restart=on-failure:5 # Restart max 5 times
Proper resource limits, monitoring, and backups are essential in production. Running containers without these is like driving without a seatbelt.
Related: CloudPanel setup | aaPanel Docker | Docker basics | Containerization
Need CloudPanel on a server?
Use CloudPanel on an UnderHost VPS or dedicated server for fast PHP app and WordPress hosting without a heavy panel stack.





















