When you move Docker Compose stack to a new VPS, the containers are the easy part. You can rebuild them in minutes from your compose file. The data is what bites: database files, uploaded media, config files, and certificates live in volumes and bind mounts that do not travel with the image.
A safe migration is really a checklist problem. Map every piece of state, back it up, copy it to the new server, restore it, and prove the new stack works before you point traffic at it. Do it in that order and the old server stays live as your fallback until the very last step.
Map Every Piece of the Stack Before You Touch Anything
Open your compose file and list everything that holds state. For each service, note its volumes, bind mounts, environment files, and external networks. Then check the host for files the compose file never mentions: .env files, reverse proxy configs, certificate directories, and cron jobs that call docker compose.
A typical stack hides state in more places than you expect: uploads in one named volume, database data in another, certificates on the host. Miss one and the migration looks fine until someone uploads a file or a certificate expires. If you are still learning how compose files fit together, our walkthrough of your first docker compose yaml file explains each section.
Write the inventory down: service name, volume name, host path, and rough size for each item. The sizes decide how long the transfer takes and whether the new VPS has enough disk.
Back Up Your Volumes the Right Way
Never copy a live database volume file by file while the database is running. You will get a half-written copy that refuses to start. Stop the stack first, or use the database’s own dump tool while it runs, then stop everything before you copy the files.
A docker compose backup volumes routine that works for most stacks looks like this:
docker compose downto stop every container cleanly.- Dump each database with its native tool, for example
mysqldumporpg_dump, and save the dump inside the backup folder. - Archive each named volume and bind mount with
tar, keeping permissions intact. - Copy the compose file,
.envfiles, and any host-side configs into the same backup folder. - Verify the archive opens and lists the files you expect before you delete anything.
For database-heavy stacks, a proper dump is worth the extra step over a raw volume copy. Our guide on how to move a MySQL database to a bigger VPS without downtime covers the dump-and-restore flow in detail.
Keep one copy of the backup on the old server and one somewhere else, even if that somewhere else is just your laptop. A migration is the worst possible moment to discover your only backup was on the disk you just wiped.
Prepare the New VPS Before the Transfer
Install Docker and the Compose plugin on the new server first, and confirm the versions match the old one closely. Create the same directory layout, the same non-root user, and the same firewall rules.
Check the basics people skip: enough free disk for the data plus room to grow, enough RAM for every service at once, and the ports your stack needs open. Copy your SSH key over so you are not pasting passwords during the transfer. If the new server runs a different Linux distribution, test that your compose file still parses with docker compose config before you copy any data.
Also plan the DNS change. If the new VPS has a different IP, lower the TTL on the affected records to five minutes a day before the move, so the switch propagates fast when you flip it.
Move Docker Compose Stack: The Step-by-Step Transfer
With the backup verified and the new server ready, the transfer itself is straightforward. When you migrate docker compose stack setups, rsync is usually the best tool because it resumes cleanly if the connection drops and only copies what changed on a second pass.
For the rsync docker volumes new server step, run the transfer from the old server or pull from the new one:
rsync -avz --progress /opt/stack-backup/ root@new-server:/opt/stack/
Use -a to preserve permissions and ownership, and -z to compress the stream. For large media folders, run the first pass while the old stack is still live, then stop the stack and run a second pass that only picks up changed files. That keeps the downtime window short.
Copy the compose file, environment files, and configs into the same directory structure they had on the old server. Paths matter: a bind mount pointing at /opt/stack/data breaks if you restore it to /root/stack/data instead. If your stack uses named volumes, create them on the new server first with docker volume create, then extract each archive into the volume’s directory under /var/lib/docker/volumes/.
Restore and Bring the Stack Up
Start with the database and other stateful services first. Restore the dump, then start the app containers one at a time and watch their logs. Starting services in order shows you exactly which one fails and why.
docker compose up -d db
docker compose logs -f db
docker compose up -d
Check each service from inside the stack before you expose it to the internet. Can the app reach the database? Does the reverse proxy see the app container? Are the uploaded files actually there? A quick docker compose ps shows running containers, but it does not prove the app works, so open the app on the new server’s IP and click through the important pages.
This is also the moment to handle updates you have been postponing. If a container image has a newer patch version, update it now while you are already testing, following the same careful process in our guide to update Docker containers without downtime.
Switch Traffic and Verify Everything
Only point DNS at the new server after the stack passes a full check on the new IP: login works, uploads work, forms submit, and scheduled jobs run. Then update the DNS records and watch the logs on both servers. Traffic drains off the old server over the next few minutes as caches expire.
Keep the old server running for at least 24 hours after the switch. If something breaks at 2 a.m., your fallback is a DNS change away, not a rebuild. If you are changing providers too, read our guide on how to move your VPS to another provider without losing your IP reputation first, because mail delivery and IP reputation need their own plan.
Moving a single container is a different job from moving a whole stack. If you only need one service on the new host, our guide on how to move Docker containers to a new VPS without downtime covers the container-level approach.
After the TTL window passes and the old server’s logs go quiet, shut the old stack down, take a final backup, and only then cancel the old VPS.
What Usually Goes Wrong
Most failed migrations trace back to the same few oversights. The .env file was never copied, so the app starts with default passwords or the wrong database host. A volume was recreated empty because the restore step was skipped. Or the compose file references a network that only exists on the old host.
Permissions deserve special attention. Rsync with -a preserves ownership, but if the user IDs differ between servers, files can end up owned by the wrong account. Check ownership inside the containers after the restore, not just on the host. A database that refuses to start after a move is almost always a permissions problem or a half-copied data directory.
Another common trap is testing only the homepage. It can render fine while uploads, search, and background jobs are broken. Test the features your users actually use, not just the page that loads first.
A Docker Compose Migration Checklist You Can Reuse
Save this list for the next move. A docker compose migration checklist worth keeping on hand covers inventory, backup, transfer, restore, and verification in that order, and it only works if you check each box before moving to the next stage.
- Inventory every volume, bind mount,
.envfile, and host-side config. - Stop the stack, dump databases, archive volumes, and verify the backup opens.
- Prepare the new VPS: Docker, disk space, firewall, SSH access, and lower DNS TTL.
- Transfer with rsync, preserving paths, permissions, and ownership.
- Restore databases, start services in order, and check logs for each one.
- Test logins, uploads, forms, and background jobs on the new IP.
- Switch DNS, watch both servers, and keep the old one for at least 24 hours.
- Cancel the old VPS only after the new stack has run clean for a full day.
A migration done this way is boring, and boring is the goal. The stack comes up, the data is all there, and the old server waits quietly in case you need it.