Skip to main content

A tool for migrating Docker applications between servers

Project description

Docker Migration Tool

This project provides a comprehensive solution for migrating Docker environments using Docker Compose. It automates the process of preparing Docker data, creating archives, transferring files to a new server, and reinstalling Docker on the new server.

Features

  • Identifies Docker images, containers, networks, and other related data from the Docker Compose file.
  • Creates backups of Docker data and packages them into zip or tar files.
  • Optionally includes additional host files specified in the Docker Compose file.
  • Transfers the created archives to a new server via VPN.
  • Extracts the archives and reinstalls Docker on the new server.
  • Validates the running state of Docker services after installation.

Project Structure

docker-migration-tool
├── src
│   ├── main.py                # Entry point of the application
│   ├── docker_utils           # Package for Docker utilities
│   │   ├── __init__.py
│   │   ├── compose_parser.py   # Parses Docker Compose files
│   │   └── docker_backup.py    # Handles Docker data backup
│   ├── archive                # Package for archiving utilities
│   │   ├── __init__.py
│   │   ├── archiver.py        # Creates and combines archives
│   │   └── extractor.py       # Extracts archives on the new server
│   ├── transfer               # Package for file transfer utilities
│   │   ├── __init__.py
│   │   └── file_transfer.py    # Transfers files via VPN
│   └── validation             # Package for validation utilities
│       ├── __init__.py
│       └── health_check.py     # Checks Docker service health
├── requirements.txt           # Project dependencies
├── setup.py                   # Packaging configuration
├── README.md                  # Project documentation
└── .gitignore                 # Git ignore file

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd docker-migration-tool
    
  2. Install the required dependencies:

    pip install -r requirements.txt
    

Usage

Basic Usage

  1. Navigate to the directory containing your Docker Compose file.
  2. Run the migration tool:
    python src/main.py
    
  3. Follow the prompts to complete the migration process.

Advanced Options

Backup Mode

python src/main.py --mode backup [options]

Options:

  • --backup-all: Backup all Docker resources on the server instead of just those in docker-compose.yml
  • --docker-src-base-dir PATH: Include a specific directory containing Docker source files in the backup
  • --skip-images: Skip backing up Docker images (which can be large)
  • --skip-containers: Skip backing up Docker containers
  • --config-only: Only backup configurations (equivalent to using both --skip-images and --skip-containers)
  • --pull-images: Pull Docker images defined in docker-compose.yml before backup
  • --transfer: Transfer the backup to another location
  • --destination PATH: Specify destination path (local path, user@host:/path for SCP, or ftp://user:pass@host/path for FTP)
  • --ftp-user USERNAME: FTP username (if not specified in destination)
  • --ftp-pass PASSWORD: FTP password (if not specified in destination)
  • --no-prompt: Do not prompt for user input (useful for scripted operations)

Restore Mode

python src/main.py --mode restore --backup-file PATH [options]

Options:

  • --backup-file PATH: Path to backup file (required for restore mode)
  • --compose-file-path PATH: Path to docker-compose.yml file for restoration
  • --extract-only: Extract files without restoring Docker components
  • --target-dir PATH: Directory to extract application files to (for extract-only mode)

Use Cases

  1. Server Migration: Migrate a complete Docker environment from one server to another.
  2. Environment Backup: Create a backup of your Docker environment before making significant changes.
  3. Disaster Recovery: Restore Docker services quickly after a system failure.
  4. Dev/Test Cloning: Clone a production environment to development or testing servers.
  5. Configuration Extraction: Extract only configuration files without the Docker images for lightweight backups.
  6. Selective Migration: Migrate specific components of your Docker environment by using skip options.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any enhancements or bug fixes.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docker_migration-0.1.0.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

docker_migration-0.1.0-py3-none-any.whl (23.5 kB view details)

Uploaded Python 3

File details

Details for the file docker_migration-0.1.0.tar.gz.

File metadata

  • Download URL: docker_migration-0.1.0.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for docker_migration-0.1.0.tar.gz
Algorithm Hash digest
SHA256 62bb93c23b58979bd32c7216bb3a0e734f7ad1e899cfc93dce5bf3b3b68a68e7
MD5 7c7a64d7446222017baae36f730a865b
BLAKE2b-256 3795429c3358073a764b19edd80de174b8a28e566b090f94e38ddbbc40b5794c

See more details on using hashes here.

File details

Details for the file docker_migration-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for docker_migration-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e21086db1d5c11e90b5860f84df014c107b5e2c2864e2b93e607343a39f161a0
MD5 33df66f19b231174e3b10c42669cd138
BLAKE2b-256 9ae13614f42016a491ad01fe7cf3f0123588af9c8698e3e82c2243e82bcee754

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page