UnderHost
Knowledgebase Docs

Docker integration in aaPanel: run containers

Run Docker containers in aaPanel. Setup Docker, manage containers, deploy apps, persistent storage, networking, monitoring containers.

On this page

Docker is a containerization platform that packages applications with all dependencies (OS, libraries, code) into portable "containers". Containers are lightweight VMs that start instantly, run identically everywhere, and simplify deployment. aaPanel integrates Docker for advanced deployment scenarios like microservices, multiple app versions, or complex architectures.

What is Docker

Docker vs traditional hosting:

  • Traditional: Install PHP, MySQL, dependencies on server → conflicts, version issues
  • Docker: Package exact app version with exact dependencies in container → works everywhere

Docker benefits:

  • Portability: Container runs identically on laptop, staging, production
  • Isolation: Containers don't interfere with each other
  • Quick startup: Containers start in seconds (vs minutes for VMs)
  • Resource efficient: Containers use 10-50% resources of VMs
  • Version control: Different app versions in separate containers simultaneously

When to Use Docker

Docker is ideal for:

  • Microservices architectures (many small apps)
  • Running multiple app versions simultaneously
  • Complex dependencies or rare packages
  • Development/staging/production parity
  • CI/CD pipelines and automated deployment

When NOT to use Docker:

  • Simple WordPress site (use standard hosting)
  • Team unfamiliar with containers (steep learning curve)
  • Single app with simple requirements

Install Docker in aaPanel

Check if Docker is installed:

docker --version
# Output: Docker version 20.x+

Install Docker (if not present):

# Debian/Ubuntu
apt update
apt install docker.io
systemctl enable docker
systemctl start docker

# Verify installation
docker run hello-world
# Should show "Hello from Docker!"

Install Docker Compose (manage multi-container apps):

curl -L "https://github.com/docker/compose/releases/download/v2.20.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version

Run Basic Containers

Run simple container (Nginx web server):

# Start Nginx container, port 8080
docker run -d -p 8080:80 --name webserver nginx

# Access at http://yourip:8080

# View running containers
docker ps

# Stop container
docker stop webserver

# Remove container
docker rm webserver

Run container with volume mount (persistent data):

docker run -d -p 3306:3306 \
  -v /data/mysql:/var/lib/mysql \
  -e MYSQL_ROOT_PASSWORD=password123 \
  --name database mysql:8.0

# Data persists in /data/mysql on host

Persistent Storage

Container data is lost when container stops. Use volumes for persistent data:

  • Named volumes: Docker-managed storage
  • Host volumes: Mount host directory into container
  • Bind mounts: Direct path mapping

Named volume example:

# Create volume
docker volume create mydata

# Run container with volume
docker run -d -v mydata:/data --name app myapp

# Data persists even if container deleted

Container Networking

Containers isolated by default. Connect them:

# Create network
docker network create mynet

# Run containers on same network
docker run -d --net mynet --name web nginx
docker run -d --net mynet --name api myapi

# Containers can reach each other: web → api (by name)

Expose ports to external world:

# Container port 8080 → Host port 8080
docker run -d -p 8080:8080 myapp

# Container port 3000 → Host port 9000
docker run -d -p 9000:3000 myapp

Monitor Containers

View container status:

docker ps            # Running containers
docker ps -a         # All containers (including stopped)
docker logs appname  # View container logs
docker stats         # Real-time resource usage

View container details:

docker inspect appname  # Detailed container info
docker exec -it appname bash  # Execute shell in container

Best Practices

  • Use tagged images: Specify version (nginx:1.24) not latest (could break)
  • One process per container: Container should do one thing well
  • Use Docker Compose: For multi-container apps (define all in yaml file)
  • Persistent data in volumes: Never lose data when container stops
  • Build custom images: Dockerfile for your specific app requirements
  • Monitor resource limits: Set memory/CPU limits to prevent runaway containers
  • Keep images updated: Regular security updates

Run container with resource limits:

docker run -d \
  --memory=512m \
  --cpus=1.0 \
  -p 8080:8080 \
  myapp
# Max 512MB RAM, 1 CPU core
Docker adds complexity—use only when needed

Docker is powerful for complex architectures but requires expertise. For simple apps (WordPress, static sites), standard hosting is simpler and more cost-effective.

Related: aaPanel setup | CloudPanel Docker | Docker basics | Containerization

Was this article helpful?

Need aaPanel hosting?

Install aaPanel on an UnderHost VPS or dedicated server when you want a simple web interface for sites, databases, SSL, and apps.

Related articles

Back to aaPanel