Skip to content

A single-file Python app that compares two Docker hosts (reachable over SSH) and lets you copy containers/images and volumes from one to the other with a friendly GUI.

Notifications You must be signed in to change notification settings

jonwestfall/docker-migrator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Docker Migrator GUI (v0.9 "Okra")

A single-file Python app that compares two Docker hosts (reachable over SSH) and lets you copy containers/images and volumes from one to the other with a friendly GUI.

Features

  • Query both hosts for:
    • Containers (all, running or stopped)
    • Volumes
    • Swarm stacks and Compose projects (beta: discovery only)
  • Show diffs and preselect items missing on destination
  • Copy volumes safely using an Alpine helper container and tar streaming over SSH
  • Copy required images for selected containers (docker save|load piped over SSH)
  • Recreate containers on the destination (name, env, ports, binds, restart policy, networks) and optionally start them
  • Optionally stop selected containers on the source during copy and restart them after

Install

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python docker_migrator.py

On Windows PowerShell:

py -3 -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
py docker_migrator.py

Requirements

  • Python 3.10+
  • Docker installed and running on both hosts
  • SSH access (password or key); the user must be able to run docker (often via docker group or sudo-less)
  • Internet on both hosts to docker pull alpine:latest if not present

How it Works

  • Volumes: We avoid touching /var/lib/docker/.... Instead we run:
    • Source: docker run --rm -v VOL:/data alpine tar -C /data -cf - .
    • Destination: docker run --rm -i -v VOL:/data alpine tar -C /data -xf -
    • We stream stdout from source to stdin on destination over SSH.
  • Images: We transfer missing images with docker image save ... | gzip piped into gunzip | docker image load.
  • Containers: We docker inspect on the source, then docker create on the destination with env, ports, binds, restart policy, and networks (bridge auto, others created if missing). We then optionally docker start it.

Note: If containers bind mount host paths (e.g., /srv/data:/data), ensure those paths exist on the destination or convert them to named volumes first.

Stacks (Beta)

We detect Swarm stacks (docker stack ls) and Compose projects (docker compose ls) but automated redeploy is limited in this version. We transfer images used by stack services; to redeploy, run your original docker stack deploy or docker compose up on the destination. Future versions may attempt to reconstruct compose files from service/container inspections, but fidelity can vary.

Safety

  • Optionally stop source containers during copy to avoid inconsistent state
  • Volume transfer uses tar; consider stopping services that write to volumes during migration
  • You can restart source containers after copying completes

Troubleshooting

  • Permission errors: Ensure SSH user can run docker without sudo, or adapt the code to prefix commands with sudo.
  • Network timeouts: Large images/volumes can take time. The stream is chunked and progress is logged at ~10MB intervals.
  • Non-default networks: The tool creates missing user-defined networks by name on the destination and connects containers.

Roadmap

  • Full stack/compose export + redeploy
  • Smarter mapping of host bind mounts
  • Progress bars per item
  • Inclusion/exclusion filters by label

About

A single-file Python app that compares two Docker hosts (reachable over SSH) and lets you copy containers/images and volumes from one to the other with a friendly GUI.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages