Docs / Migration Guides / How to Migrate Docker Containers Between Hosts

How to Migrate Docker Containers Between Hosts

By Admin · Mar 2, 2026 · Updated Apr 24, 2026 · 30 views · 3 min read

How to Migrate Docker Containers Between Hosts

When moving workloads to a new Breeze instance, you may need to migrate running Docker containers along with their data volumes. This guide covers multiple approaches to Docker migration depending on whether you use Docker Compose, standalone containers, or need to preserve runtime state.

Approach 1: Migrate with Docker Compose (Recommended)

If your application is defined with Docker Compose, migration is straightforward because the entire stack is described in code:

On the Source Server

Copy the project directory including the docker-compose.yml, environment files, and any persistent data:

rsync -avz /opt/myapp/ user@new-breeze-ip:/opt/myapp/

On the New Breeze

Install Docker and Docker Compose, then bring up the stack:

cd /opt/myapp
docker compose up -d

Approach 2: Export and Import Container Images

If you have custom-built images not available from a registry, export them as tar archives:

# On the source server
docker save myapp:latest | gzip > myapp-image.tar.gz
scp myapp-image.tar.gz user@new-breeze-ip:/tmp/

# On the new Breeze
docker load < /tmp/myapp-image.tar.gz
docker run -d --name myapp -p 8080:8080 myapp:latest

Approach 3: Commit a Running Container

If you need to capture the current state of a running container, including any changes made since it started:

# On the source server
docker commit mycontainer mycontainer-snapshot:v1
docker save mycontainer-snapshot:v1 | gzip > snapshot.tar.gz
scp snapshot.tar.gz user@new-breeze-ip:/tmp/

# On the new Breeze
docker load < /tmp/snapshot.tar.gz
docker run -d --name mycontainer mycontainer-snapshot:v1

Migrating Docker Volumes

Persistent data stored in Docker volumes must be migrated separately. First, identify the volume mount paths:

docker inspect mycontainer --format '{{ range .Mounts }}{{ .Source }} -> {{ .Destination }}{{ "\n" }}{{ end }}'

Then transfer the volume data:

# Backup the volume to a tar archive
docker run --rm -v myvolume:/data -v /tmp:/backup alpine tar czf /backup/myvolume.tar.gz -C /data .
scp /tmp/myvolume.tar.gz user@new-breeze-ip:/tmp/

# Restore on the new Breeze
docker volume create myvolume
docker run --rm -v myvolume:/data -v /tmp:/backup alpine tar xzf /backup/myvolume.tar.gz -C /data

Using a Private Registry

For teams that build many images, pushing to a private registry simplifies migration. Push from the source and pull on the Breeze:

# Source server
docker tag myapp:latest registry.example.com/myapp:latest
docker push registry.example.com/myapp:latest

# New Breeze
docker pull registry.example.com/myapp:latest

Post-Migration Checklist

  • Verify all containers are running with docker ps
  • Test connectivity to exposed ports
  • Confirm volume data is intact by checking logs and querying databases
  • Re-create any Docker networks if containers need to communicate
  • Set up container auto-restart policies with --restart unless-stopped

Was this article helpful?