docker/migrator

Name: migrator

Owner: Docker

Description: Tool to migrate Docker images from Docker Hub or v1 registry to a v2 registry

Created: 2015-07-21 18:33:19.0

Updated: 2018-05-22 14:15:19.0

Pushed: 2018-05-22 14:15:16.0

Homepage:

Size: 154

Language: Shell

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

docker/migrator

Tool to migrate Docker images from Docker Hub or v1 registry to a v2 registry including Amazon EC2 Container Registry (ECR)

https://hub.docker.com/r/docker/migrator/

Usage
er run -it \
-v /var/run/docker.sock:/var/run/docker.sock \
-e V1_REGISTRY=v1.registry.fqdn \
-e V2_REGISTRY=v2.registry.fqdn \
docker/migrator
Environment Variables

The following environment variables can be set:

Required Optional

Note: You must use all three variables (V1_USERNAME, V1_PASSWORD, and V1_EMAIL or V2_USERNAME, V2_PASSWORD, and V2_EMAIL) for the given automated docker login to function properly. Omitting one will prompt the user for input of all three.

Prerequisites

This migration tool assumes the following:

It is suggested that you run this container on a Docker engine that is located near your registry as you will need to pull down every image from your v1 registry (or Docker Hub) and push them to the v2 registry to complete the migration. This also means that you will need enough disk space on your local Docker engine to temporarily store all of the images. If you have limited disk space, it is suggested that you use the MIGRATION_INCREMENT option to migrate n number of images at a time.

If you're interested in migrating to an Amazon EC2 Container Registry (ECR) you will additionally need to supply your AWS API keys to the migrator tool. This can be accomplished in one of the two following ways:

er run -it \
-v ~/.aws:/root/.aws:ro \
-v /var/run/docker.sock:/var/run/docker.sock \
-e V1_REGISTRY=v1.registry.fqdn \
-e V2_REGISTRY=v2.registry.fqdn \
er/migrator

er run -it \
-v /var/run/docker.sock:/var/run/docker.sock \
-e AWS_ACCESS_KEY_ID=<key> \
-e AWS_SECRET_ACCESS_KEY=<secret> \
-e V1_REGISTRY=v1.registry.fqdn \
-e V2_REGISTRY=v2.registry.fqdn \
er/migrator
How Migration Works

The migration occurs using an automated script inside of the Docker container. Running using the above usage will work as expected.

  1. Login to the v1 registry or Docker Hub (Optional)
  2. If you do not have authentication enabled, leave the username blank when prompted
  3. Query the v1 registry or Docker Hub for a list of all repositories
  4. With the list of images, query the v1 registry or Docker Hub for all tags for each repository. This becomes the list of all images with tags that you need to migrate
  5. Using a Docker engine, pull all images (including each tag)
  6. Once all images are pulled, there are a few options for next steps:
  7. If the same DNS record will be used for the v1 and v2 registries:
    • Have user switch the DNS record over to the new server's IP or if same box to be used, stop the v1 registry and start the v2 registry
  8. If a different DNS record will be used for the v1 and v2 registries:
    • Re-tag all images to change the tagging from the old DNS record to the new one
  9. Login to the v2 registry (Optional)
  10. If you do not have authentication enabled, leave the username blank when prompted
  11. Push all images and tags to the v2 registry
  12. Verify v1 to v2 image migration was successful (not yet implemented)
  13. Cleanup local docker engine to remove images

asciicast

Logging Migration Output

If you need to log the output from migrator, add 2>&1 | tee migration.log to the end of the command shown above to capture the output to a file of your choice.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.