Tool to migrate Docker images from Docker Hub or v1 registry to a v2 registry including Amazon Elastic Container Registry (ECR)
https://hub.docker.com/r/docker/migrator/
docker 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
The following environment variables can be set:
V1_REGISTRY
- DNS hostname of your v1 registry or Docker Hub (Do not include https://
)
docker.io
V2_REGISTRY
- DNS hostname of your v2 registry (Do not include https://
)AWS_ACCESS_KEY_ID
- AWS Access Key supplied as either an environment variable or as a part of your credentials file.AWS_REGION
- AWS Region, must be specified if using ECRAWS_SECRET_ACCESS_KEY
- AWS Secret Access Key supplied as either an environment variable or as a part of your credentials file.ERROR_ACTION
- Sets the default action on error for pushes and pulls
prompt
- (Default) Prompt for user input as to what action to take on errorretry
- Retry the failed action on error (may cause infinite loop of failure)skip
- Log the error and continue migration on errorabort
- Abort the migration on errorMIGRATION_INCREMENT
- Breaks up migration in chunks of n
images
USER_PROMPT
- Sets the default action for user prompts (non-error)
true
- (Default) Prompts user for input/validationfalse
- Skips user prompt and automatically proceedsNO_LOGIN
true
- Skips docker login
for both the v1 and v2 registriesfalse
- (Default) Prompts user to login to the v1 and v2 registriesV1_NO_LOGIN
true
- Skips docker login
for the v1 registryfalse
- (Default) Prompts user to login to the v1 registryV2_NO_LOGIN
true
- Skips docker login
for the v2 registryfalse
- (Default) Prompts user to login to the v2 registryUSE_INSECURE_CURL
true
- Allows curl to perform insecure SSL connections for querying APIsfalse
- (Default) Require curl to perform secure SSL connections for querying APIsUSE_HTTP
true
- Allows curl to connect to both the v1 and v2 registries over HTTP
--insecure-registry
option setfalse
- (Default) Requires curl to connect to v1 and v2 registries over HTTPSV1_USE_HTTP
true
- Allows curl to connect to v1 registry running over HTTP
--insecure-registry
option setfalse
- (Default) Requires curl to connect to v1 registry over HTTPSV2_USE_HTTP
true
- Allows curl to connect to v2 registry running over HTTP
--insecure-registry
option setfalse
- (Default) Requires curl to connect to v2 registry over HTTPSDOCKER_HUB_ORG
- Docker Hub organization name to migrate images from
V1_FULL_REPO_LIST
_search
(some setups might have search disabled)V1_REPO_FILTER
- Search filter to limit the scope of the repositories to migrate (uses grep basic regular expression interpretation)
V1_TAG_FILTER
- Search filter to limit the scope of the tags to migrate (Plain text matching).LIBRARY_NAMESPACE
- Sets option to migrate official namespaces (images where there is no namespace provided) to the library/
namespace (Note: must be set to true
for DTR 1.4 or greater)
true
- (Default) Adds library
namespace to image namesfalse
- Keeps images as they are without a namespaceSKIP_EXISTING_TAGS
- Option to skip tags that exist at the target repository
true
- Do not migrate tags that exist at the target repositoryfalse
- (Default) Do not skip any tags-v /etc/docker/certs.d:/etc/docker/certs.d:ro
V1_USERNAME
- Username used for docker login
to the v1 registryV1_PASSWORD
- Password used for docker login
to the v1 registryV1_EMAIL
- Email used for docker login
to the v1 registryV2_USERNAME
- Username used for docker login
to the v2 registryV2_PASSWORD
- Password used for docker login
to the v2 registryV2_EMAIL
- Email used for docker login
to the v2 registryNote: 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.
This migration tool assumes the following:
V1_REGISTRY
and V2_REGISTRY
to the same value.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 Elastic 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:
docker 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 \
docker/migrator
docker 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 \
docker/migrator
The migration occurs using an automated script inside of the Docker container. Running using the above usage will work as expected.
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.