To isolate multiple sites on one VPS, give each site its own container, its own files, and its own network space, then put a single reverse proxy in front. When one site breaks, gets hacked, or eats all the memory, the others keep running. That separation is the main reason to run Docker on a shared server instead of stacking every site into one web server config.
A shared server without isolation is fragile in quiet ways. One site with a bad plugin can fill the disk with logs. One site with a traffic spike can starve the rest of CPU. One compromised upload folder can expose every other site on the same machine. Containers do not remove those risks, but they put walls between them, so a problem stays in one place while you fix it.
Why isolate multiple sites
Isolation buys you four things. First, fault separation: a crash in one site does not take the others down. Second, security separation: a breach in one container does not hand over every site’s files by default. Third, dependency freedom: one site can run PHP 8.1 while another runs PHP 8.3, because each container carries its own runtime. Fourth, clean removal: deleting a site means deleting its container and volumes, not untangling shared config files.
The cost is real too. Containers use some extra memory, and you now manage more moving parts: images, volumes, networks, and a proxy. For two or three small sites, that cost is small. For a server full of client sites, it is the price of sleeping well. If you are still deciding how containers fit beside other tools, the comparison of Docker Compose versus Kubernetes helps you judge when Compose is enough.
One container per site, one job per container
Start with a simple rule: one container runs one site’s app, and supporting services get their own containers. A WordPress site, for example, gets an app container and a database container, not a single container with both jammed inside. That split lets you restart, back up, and scale each part on its own.
Keep each site’s files in a named volume or a bind mount under that site’s own folder, such as one directory per site under a sites folder. This docker containers per site pattern is the core of vps site isolation, and it scales to docker compose multiple websites without shared state.
Use a small Compose file per site rather than one giant file for everything. A per-site file is easier to read, easier to hand to a teammate, and safer to change: editing one site’s file cannot break another site’s config. Small images help as well, and the guide to multi-stage Dockerfiles that shrink images shows how to keep them lean.
Separate networks for each site
Docker lets you create a network per site. Put a site’s app container and its database container on that site’s network, and keep other sites off it. Containers on different networks cannot reach each other by name, which stops a compromised app container from scanning its neighbors.
The reverse proxy is the exception. It needs to reach every site’s app container, so it joins each site network, or each app container joins a shared proxy network while its database stays on the private site network. Either pattern works. The key point is that databases never sit on a shared network. A database should answer only to its own app.
Also, do not publish database ports to the host. A database port open to the internet invites password guessing, and a port open on localhost is still reachable by anything else on the server. Keep database access inside the container network, and use a temporary container or an SSH tunnel when you need direct access.
One reverse proxy in front of everything
Run one proxy, such as Nginx or Traefik, as the only container that listens on ports 80 and 443. Each site’s app container listens only on its private network. The proxy reads the Host header and routes each request to the right container, and it handles TLS certificates for all domains in one place.
This layout has a practical bonus: adding a site means adding its containers and one proxy rule, not touching a shared server config that every site depends on. Removing a site means removing its containers and its proxy rule. Nothing else changes. Before you point a new domain at this setup, test the whole layout on a spare machine with a staging environment on a separate VPS so mistakes happen there, not on live client sites.
Resource limits per site
Isolation without limits is half done. A runaway site can still eat all CPU or memory if nothing caps it. Set memory limits and CPU limits on each app container, sized to what the site normally needs plus headroom. When a site hits its cap, that site slows down or restarts, while the rest stay healthy. That is the outcome you want.
Set disk limits too, or at least watch disk use per site. Logs are the usual culprit: one verbose app can fill a disk overnight and crash every container on the host. Turn on log rotation in Compose, cap log size, and check disk use weekly. A simple monitoring alert for disk above 80 percent saves more outages than most tuning tricks.
Backups follow the same split. Back up each site’s volumes and database separately, and label each backup with the site name and date. A per-site backup restores one site without touching the others, which is exactly what you need when one client asks for a restore and the rest must stay untouched.
Updates without cross-site breakage
With isolation, you can update one site at a time. Pull a new image for one site, restart only that site, check it, then move on. If the update breaks something, roll back that site’s container while the others keep serving. Compare that with a shared server, where a PHP version bump or a library upgrade can break five sites at once.
Keep a short update routine: snapshot or back up the site, pull the new image, restart, check the homepage and one key page, and watch logs for a few minutes. Write down any site that needs a pinned version, so a future update does not surprise you. Pinning matters: an unpinned “latest” tag can change under you overnight, and you will spend the morning guessing which site changed.
Security habits that keep isolation honest
Containers help, but habits keep them honest. Run containers as a non-root user where the image allows it. Keep the Docker socket out of app containers, since access to that socket is close to root on the host. Keep the host itself patched and locked down; container walls mean little if the host is wide open, so the steps in the guide to hardening a fresh Ubuntu server still apply underneath Docker.
Scan images you pull from public registries, prefer official or well-kept images, and update base images on a schedule. Also review who can run Docker on the host: anyone in the docker group can effectively become root, so keep that group small and trusted.
A practical checklist
Before you call the setup done, check each item per site. One Compose file per site, one network per site, database ports unpublished, proxy as the only public entry point, memory and CPU limits set, log rotation on, per-site backups tested with a real restore, and an update routine written down. Miss one item and the gap will show up at the worst time.
Done this way, a single VPS can host many sites without them sharing fate. Each site gets its own walls, its own limits, and its own way out when things go wrong, and you get a server you can reason about one site at a time.