Skip to main content Migrating From Docker To Docker Swarm : r/docker
r/docker icon
Go to docker
•
[deleted]

Migrating From Docker To Docker Swarm

Hello, I've done some research online, and haven't been able to find anything with regards to migrating from a non docker-swarm infra, to a docker-swarm based infra.

Right now our services are managed across multiple docker hosts using docker-compose files and ansible playbooks. However I'm looking to shift this to a docker-swarm based setup for easier management, and high-availability. I'm looking to make the migration as least disruptive as possible, but unfortunately there doesn't appear to be much documentation on this process.

As far as I can tell, the most straight forward way to make this migration will be to bring each of the docker hosts offline 1-by-1, migrating the host to swarm mode. After migrating the first host to docker-swarm, I will redeploy the services to that host. After the services are confirmed working, I'll begin migrating the remaining hosts, joining them to the swarm as needed. Once all docker hosts are part of the swarm, I'll then scale the services across all new hosts. Does this sound about right?

Earn CPE credits 🎓 and level up your skills! Join us April 3 at 11 AM ET for a live hack—build an AI-generated app & uncover real security flaws in AI-assisted code!
Thumbnail image: Earn CPE credits 🎓 and level up your skills! Join us April 3 at 11 AM ET for a live hack—build an AI-generated app & uncover real security flaws in AI-assisted code!
Sort by:
Best
Open comment sort options

You can run local containers workloads in Docker Swarm so you can enable swarm mode on all your nodes and link them while keeping your existing workload intact. Then you just have to port your existing docker-compose files to use the v3 syntax, add some deployment constraints (so they end on the same host as the old service), stop your old service and deploy the new one on the swarm.

You can do this for every compose file until all of then are migrated. After that you could remove the constraints for services without local volumes so they are started on any node.

Once all docker hosts are part of the swarm, I'll then scale the services across all new hosts.

Note that this only make sense for your stateless services. Docker swarm isn't magic and won't make your stateful services (like databases or applications that use local volumes to store data) highly available.

Note: i am almost 100% sure that doing a docker swarm init won't disrupt your current containers but make some tests first as i haven't used non swarm containers in years so i could be wrong.

More replies