🐳
Hosting

Running Multiple Projects on One VPS with Docker

18.11.2026
← All articles

As your projects multiply, a separate server for each becomes expensive and tedious to manage. Installing everything directly on one VPS creates a different problem: one site needs PHP 8.3, another only runs on 7.4, and a third expects a specific Node.js version. Docker resolves the conflict. Each project lives in its own container with its own libraries and settings, isolated from the others.

What Docker does and does not give you

A container packages an application with everything it depends on, so what works on a developer's laptop works the same on the server, and removing a project leaves no leftovers. But Docker is not a virtual machine: all containers share one kernel and the same physical resources, so one runaway project can slow the rest unless you set limits. Docker also does not back anything up by itself; volumes holding databases and uploads need their own backups.

Preparing the server

curl -fsSL https://get.docker.com -o get-docker.sh
less get-docker.sh          # review it first
sudo sh get-docker.sh
sudo usermod -aG docker $USER
docker compose version

# /etc/docker/daemon.json - cap log size for new containers
{
  "log-driver": "json-file",
  "log-opts": { "max-size": "10m", "max-file": "3" }
}
sudo systemctl restart docker

Architecture: one proxy, many projects

Only one container can own ports 80 and 443, so a reverse proxy sits in front and routes requests by domain name. Caddy is convenient because it obtains and renews Let's Encrypt certificates automatically; Traefik and Nginx are common alternatives. Every project joins a shared Docker network with the proxy and publishes no ports of its own.

docker network create proxy

# /srv/proxy/compose.yaml
services:
  caddy:
    image: caddy:2
    restart: unless-stopped
    ports: ["80:80", "443:443"]
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - caddy_data:/data
    networks: [proxy]
volumes:
  caddy_data:
networks:
  proxy:
    external: true

# /srv/proxy/Caddyfile
shop.example.uz {
    reverse_proxy shop-app:3000
}
blog.example.uz {
    reverse_proxy blog-wp:80
}

Each project in its own compose file

Keep each project in its own folder with its own compose.yaml and .env, so it can be updated, stopped or moved independently. The database stays on the project's internal network only.

# /srv/blog/compose.yaml
services:
  blog-wp:
    image: wordpress:php8.3-apache
    restart: unless-stopped
    environment:
      WORDPRESS_DB_HOST: blog-db
      WORDPRESS_DB_USER: wp
      WORDPRESS_DB_PASSWORD: ${DB_PASSWORD}
      WORDPRESS_DB_NAME: wp
    volumes: [wp_files:/var/www/html]
    mem_limit: 512m
    cpus: 0.5
    networks: [proxy, internal]
  blog-db:
    image: mariadb:11
    restart: unless-stopped
    environment:
      MARIADB_DATABASE: wp
      MARIADB_USER: wp
      MARIADB_PASSWORD: ${DB_PASSWORD}
      MARIADB_RANDOM_ROOT_PASSWORD: "1"
    volumes: [db_data:/var/lib/mysql]
    mem_limit: 512m
    networks: [internal]
volumes:
  wp_files:
  db_data:
networks:
  proxy:
    external: true
  internal:

Example: a small web studio

A Tashkent web studio runs three projects on one 4 GB VPS: a bakery's WordPress site, a Node.js booking app for a driving school and its own CRM, each capped at 512 MB to 1 GB of memory. A bad plugin on one site used to slow the whole server; now the problem stays inside one container and shows up immediately in docker stats. Adding a client means copying a folder, editing .env and adding three lines to the Caddyfile.

Security notes

When Docker publishes ports it writes its own iptables rules, which can bypass ufw, so a port closed in ufw may still be reachable. Do not publish database ports, or bind them to localhost such as "127.0.0.1:5432:5432". Keep passwords in .env outside Git, pin image tags and update images on your own schedule with docker compose pull && docker compose up -d.

Backing up volumes

docker compose exec -T blog-db sh -c 'mariadb-dump -u wp -p"$MARIADB_PASSWORD" wp' | gzip > /backup/blog_db_$(date +%F).sql.gz
docker run --rm -v blog_wp_files:/data -v /backup:/backup alpine   tar czf /backup/blog_files_$(date +%F).tar.gz -C /data .

Volume names are usually prefixed with the project folder name; check with docker volume ls. This setup works well on a sayt.uz VPS: start with a modest plan and scale up based on what docker stats shows.

Related articles

🧭 Self-Hosting a Vector Database: Qdrant and pgvector 🧭 Portainer: Managing Docker from Your Browser 💾 How to Restore a Site and Database from Backup in ISPmanager 🤝 Reseller hosting in Uzbekistan: hosting client sites the organised way
🌐 Language
🇺🇿 O'zbek 🇺🇿 Ўзбек 🇷🇺 Русский 🇬🇧 English ✓