Skip to content
zhou.
← Blog

Migrating a Bare-Metal Service to Docker: My Experience

4 Aug 2026 · 5 views

Today I moved all of my personal site's infrastructure into containers, so here's a write-up of how it went.

Config

The machine is a Compute Engine instance rented on GCP. With a long-term commitment contract plus the monthly Google Developer renewal, the new AMD machines come out to roughly £19/month — 1 core (2 vCPU) + 100 GB SSD, running Ubuntu 25.04.

Before

The old deployment setup was: the Go backend compiled to a binary and handed to systemd to manage startup, the frontend compiled to static files and served through Caddy, and MySQL installed directly on the host as well. The problem with this is that the server was a mess — both the files and the environment. The servers at work are just as chaotic, sure, but for my own stuff I'd rather keep things tidy. On top of that, I'm a big fan of Docker (I'm a C++ programmer, so for us this thing is basically our package manager), so I decided to take a shot at the migration myself.

Migration

The first step was splitting the services apart: one Go container, one Next container, one Caddy container, and one MySQL container. All of them have images you can just pull, and the Dockerfiles were easy to write. The trickier part to plan was bringing the containers up (Compose). The four containers are independent, but within the logic of this service they belong together, so the Compose file took a bit more work. For volume mounts, the main things were mapping the local static assets (images and video) into both Caddy and the backend, with Caddy acting as the reverse proxy, plus mounting some ordinary config files and the like. Then there's networking — Compose networking is fantastic; you can just write the container name in the Compose file and reach another container's service directly. And dependencies: MySQL comes up first, then the frontend and backend, and Caddy last.

You also want to think about file layout when deploying. Keep the container-launching stuff separate from the source code — I have an apps/ directory dedicated to the Docker Compose files and the resources that need to be mounted, and a separate src/ directory just for source code.

Agents are also very good at migration-type tasks, so the whole migration succeeded on the first try. The site was only down for two or three minutes before it was back online.

The end of day...

The most agonizing part of the whole process: my VPS is in the Netherlands, so when I SSH in, the echo lag is absolutely brutal. Windows has no native mosh either — though honestly, mosh is just as laggy half the time anyway.