docker
Moving a Docker Compose Stack to a New Server
A plain-English guide to moving a Docker Compose app to a new server without losing data, breaking domains, or forgetting how it was wired together.
Your app works on the old server, and the scary part is simple: you do not want the move to turn into lost data, broken logins, or a website that disappears for hours.
Short version: to move Docker Compose to a new server, you need to move the Compose file, the environment settings, the persistent data, and the domain or proxy setup that sends visitors to the right container. The risky parts are usually not Docker Compose itself, but forgotten volumes, secret values, open ports, HTTPS certificates, and database state.
What do you actually need to move?
Think of a Docker Compose stack like a small restaurant.
The compose.yaml file is the floor plan. It says which rooms exist: the web app, the database, the cache, the background worker, and maybe a reverse proxy.
The environment file is the recipe book. It holds values like database passwords, app secrets, email settings, and API keys. If you forget it, the containers may start, but the app will behave like it has amnesia.
The volumes are the pantry. A Docker volume is storage that lives outside the container so data survives restarts. This is where databases, uploaded files, user content, and application state often live. If you only copy the Compose file and skip the volumes, you have moved the empty building, not the business.
You may also need the parts around the stack: domain records, firewall rules, HTTPS certificates, scheduled jobs, backups, and any files mounted from the server into a container.
If Docker itself still feels fuzzy, our beginner guide to Docker explains the container-and-volume idea in plainer terms: /blog/docker-on-server-for-beginners.
What breaks most often when you move Docker Compose?
The most common failure is missing persistent data. A database container can be recreated in seconds, but the actual database files need to come with it. The same goes for uploads, media libraries, search indexes, and generated assets.
The second common failure is a different path. Your old server may have used /srv/app/uploads, while the new one uses another folder. Docker Compose is literal. If a file path points to a place that does not exist, the container may start with an empty folder and make the problem look normal at first.
The third is secrets and environment variables. A missing APP_KEY, SECRET_KEY_BASE, database password, or OAuth callback setting can produce strange symptoms: login loops, invalid sessions, broken emails, or a blank error page.
Networking can also trip you up. The new server may not have the same ports open. A firewall may block traffic. A reverse proxy may point to the wrong internal port. DNS, which is the internet’s address book, may still point your domain at the old server. If the site is reachable but not loading correctly, this three-layer troubleshooting guide helps separate domain, server, and app problems: /blog/why-is-my-website-not-loading.
HTTPS is another easy one to overlook. A wrong or expired certificate can make the browser show a privacy warning even when the app itself is fine. If your old setup handled certificates automatically, make sure the new one does too before you switch traffic.
What is the safest order to move a Docker Compose stack?
Start by taking inventory before touching anything. Write down the containers, volumes, mounted folders, environment files, domains, ports, cron jobs, and backup locations. This list is your map. Without it, you are moving in the dark.
Next, prepare the new server while the old one is still running. Install what the stack needs, recreate the same folder layout where possible, and place the Compose files and environment files where they belong. The goal is to make the new place look familiar to the app.
Then move the data. For a database, that usually means taking a proper database dump or copying the volume while the app is stopped, depending on the database and how much downtime you can accept. For uploaded files and mounted folders, it means copying the actual file contents, not just the folder names.
After that, start the stack on the new server without sending real visitors there yet. Check logs, log in, upload a test file, send a test email, and confirm the app can talk to its database, cache, workers, and storage.
Only then should you switch the domain. Domain records can take time to update, so lower the time-to-live value ahead of the move if you can. That value tells other computers how long to remember the old address.
For the backup side of this, the important part is not merely “having a backup.” It is knowing you can restore it. This guide covers that mindset: /blog/back-up-your-server.
How do you avoid downtime and lost data?
Downtime is the gap between the old restaurant closing and the new one serving customers. You reduce it by doing as much preparation as possible before the final switch.
For mostly static apps, this can be simple: copy files, start the new stack, test it, then point the domain at the new server.
For apps with active users, the final data sync matters. If someone places an order, uploads a file, or changes a password during the move, that change can be left behind on the old server. That is why many migrations include a short maintenance window: pause writes, copy the final data, test, and then switch traffic.
Also check background jobs. A queue worker running on both old and new servers can process the same task twice. A scheduled job running in two places can send duplicate emails or charge a customer twice. During the cutover, know which server is allowed to do work.
The shortcut
Server Manager helps by turning the move into a visible setup instead of a pile of remembered steps. The outcome is that the app, domains, HTTPS, and related services stay connected in a way you can read later, not just in the moment you built them.
That matters for the exact problems that make Docker Compose moves stressful: a forgotten environment value, a wrong domain target, an expired or mismatched certificate, one project breaking another, or losing track of which service owns which port months later.
The real benefit is not avoiding every technical detail. It is keeping the shape of the stack understandable over time, so the next move, restore, or repair starts from a clear picture instead of guesswork.
FAQ
**Can I just copy the compose.yaml file?** No. That moves the plan, not the data. You also need volumes, mounted folders, environment files, and the surrounding domain or proxy setup.
Should I move Docker volumes or export the database? For databases, a proper export is often safer because it captures the data in a database-aware format. For uploaded files and simple app storage, copying the files is usually the point.
Do I need to stop the old stack first? Not for the whole preparation phase. But for the final data copy, you may need to pause writes so new changes are not left behind.
Why does the app start but show old or empty data? It usually means the container is using a new empty volume, a wrong mounted path, or a different database connection than you expected.
When should I switch the domain? After the new stack starts cleanly, the data is present, HTTPS works, and you have tested the app using the new server directly or through a temporary address.
What does a clean move look like?
A clean Docker Compose migration is not dramatic. The new server is prepared first, the real data is copied carefully, the stack is tested before visitors arrive, and the domain is switched only when the app behaves correctly.
You win when there is no mystery left: you know where the data lives, which settings matter, how traffic reaches the app, and how to restore the setup later. That is the difference between moving a stack and merely hoping it starts somewhere else.