How to Migrate a Docker App Between VPS Providers Without Downtime

A docker migration without downtime is mostly planning, not speed. The move itself, copying images and data to a new server, takes minutes or hours depending on size. The downtime comes from the parts people skip: a volume left behind, a database that stops syncing, or DNS that still points at the old box. This guide walks through how to migrate docker app between vps providers in a way that keeps the old server live until the new one proves it works. Use it to move docker containers to new server hardware without guessing, and keep the old box running as your fallback until the switch is done.

How to Migrate Docker App Between VPS Hosts Step by Step

The move has five phases: inventory, preparation, data copy, test, and cutover. Do them in order, and do not shut down the old server until the new one has served real traffic for at least a day.

  1. List everything the app needs: images, volumes, environment files, cron jobs, and external services.
  2. Prepare the new VPS and deploy the stack against a test domain.
  3. Copy the data and sync the database.
  4. Test the new server with real requests.
  5. Lower DNS TTL, switch traffic, and watch the logs.

Inventory First: What Actually Needs to Move

Open your Compose file and list every volume, bind mount, environment file, and network by hand. Then check the running containers for anything the Compose file does not mention: a cron job inside a container, a file uploaded to a path you forgot, or a secret stored only in the old server’s shell history. Plan the docker volumes backup and restore step before you copy anything: list every named volume, note its size, and decide whether it moves with rsync, a tar archive, or a database dump. If you are unsure which storage type a path uses, read our guide to deciding between Docker volumes and bind mounts before you move it, because the copy method differs.

Also list the things outside Docker: DNS records, firewall rules, backup scripts, and monitoring alerts.

Prepare the New VPS

Install the same Docker version on the new server, or as close as you can get, and copy the Compose files and environment files over. Do not edit secrets in transit; copy the .env file with scp and check its permissions after it lands. Open the same firewall ports as the old server, and point a test subdomain at the new IP so you can reach the stack before DNS moves.

# on the new server
docker compose pull
docker compose up -d
docker compose ps
curl -I https://test.example.com/health

Bring the stack up with empty data first and confirm it starts clean. If it does not start with no data, the problem is the config, not the copy, and you want to find that out now.

Copy Images, Volumes, and the Database

For images, the clean path is a registry: push from the old server and pull on the new one. If you have no registry, save and load the images directly:

# on the old server
docker save myapp:latest | gzip > myapp.tar.gz
scp myapp.tar.gz root@new-server:/tmp/

# on the new server
gunzip -c /tmp/myapp.tar.gz | docker load

For volumes, stop the app container briefly, or use a temporary container to read the volume while the app keeps running. A short read-only pause is safer than copying files while the database writes to them:

# copy a named volume to the new server
docker run --rm -v app_data:/data -v /tmp/backup:/backup 
  alpine tar czf /backup/app_data.tar.gz -C /data .
scp /tmp/backup/app_data.tar.gz root@new-server:/tmp/
# on the new server, restore into the same named volume
docker run --rm -v app_data:/data -v /tmp:/backup 
  alpine tar xzf /backup/app_data.tar.gz -C /data

For the database, use its own dump tool rather than copying raw files. A Postgres dump, for example, is portable across servers and versions in a way raw data files are not:

docker compose exec db pg_dump -U app appdb > appdb.sql
scp appdb.sql root@new-server:/tmp/
docker compose exec -T db psql -U app appdb < /tmp/appdb.sql

Our guide to database migrations without downtime covers the same pattern in more depth, including how to handle schema changes during a move. While you are at it, confirm the new server has its own backups configured; a migration is a good time to set up off-site backups to Backblaze B2 with Restic instead of copying the old backup job blindly.

Sync the Database and Cut Over

The hard part of any migration is the data written after your first copy. For a small app with light traffic, the simple approach works: put the app in read-only mode or show a short maintenance page, take a final dump, restore it on the new server, and switch DNS. The read-only window is usually a few minutes, and users see a clear message instead of errors.

For apps that cannot pause writes, set up replication from the old database to the new one and let it catch up before the switch. That takes more setup, but it shrinks the cutover window to seconds. Either way, run one final check after the last sync: compare row counts on the largest tables on both servers before you move traffic.

Lower DNS TTL and Switch Traffic

At least a day before the move, lower the TTL on the app’s DNS records to 300 seconds. That way, when you change the record, resolvers pick up the new IP within minutes instead of hours. Do not skip this step; a high TTL is the most common reason a “finished” migration still sends users to the old server the next morning.

When the new server is tested and the data is synced, update the DNS record to the new IP and watch both servers’ logs. Traffic should drain off the old box within minutes. Leave the old server running for 24 to 48 hours, and check its logs for stragglers: a webhook, a cron job, or a hard-coded IP that still talks to the old address.

Test Everything Before You Declare Victory

Test the new server the way a user would, not the way a developer would. Log in, place an order or submit a form, upload a file, reset a password, and confirm the email arrives. Then test the paths nobody thinks about: the webhook endpoint, the scheduled job, and the admin panel. A green health check only proves the container started; it says nothing about the checkout flow.

If your deploy process supports it, run the same checks against the new server while it is still on the test subdomain, then repeat them after DNS switches. Our walkthrough of blue-green deploys on a single VPS shows a related pattern: keep the old version live until the new one proves itself, and only then send it traffic.

Roll Back If Something Breaks

A rollback plan is part of the migration, not an afterthought. If the new server fails after the switch, flip DNS back to the old IP and the old server takes over again, because you never shut it down. The risk is data written to the new server after the switch; if users created records there, you need to copy those back before you roll back, or accept losing them. Keep the rollback window short: the longer the new server runs, the harder a rollback gets.

Tag the images you deploy so you can return to the exact version that was running before the move. Our guide to rolling back a broken deployment with Docker tags covers the tagging habit that makes this painless.

Mistakes That Cause Downtime

  • Copying the app but forgetting a volume, so uploads and sessions vanish on the new server.
  • Moving the database with raw files instead of a dump, then finding the new server cannot read them.
  • Leaving DNS TTL at a day or more, so half your users reach the old server for hours.
  • Shutting down the old server before the new one has served real traffic.
  • Forgetting cron jobs, backup scripts, and monitoring alerts that lived outside Docker.
  • Testing only the homepage and missing a broken checkout, webhook, or scheduled job.

Start the move by lowering DNS TTL today and listing every volume the app uses. Once the inventory is written down, the rest of the migration is just copying files in order and testing before you switch traffic.

Ditulis oleh

Firdaus Safari Putra

Founder, PT FirKaizen Digital Solutions

Firdaus Safari Putra adalah founder PT FirKaizen Digital Solutions. Ia membangun dan mengoperasikan infrastruktur server di balik panduan ini, dan menulis berdasarkan apa yang benar-benar ia jalankan, uji, dan ukur — bukan teori.