Skip to content

Migrating Container Registries from ECR to JFrog Artifactory

This method uses a tool provided by JFrog that is intended to be the optimized method for migrating registry images with control over which images and tags are migrated.

Prerequisites

This tool uses Python 2, that can be installed from here.

You will need AWS CLI Version 1 or 2 for Docker authentication. Depending on the version you have, the commandline inputs will be different.

Setup

Clone the jfrog-docker-migration repository that contains the tool, you can run this locally.

v1 Commands aws ecr get-login --no-include-email docker login -u AWS -p password https://aws_account_id.dkr.ecr.us-east-1.amazonaws.com

V2 Commands aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin https://aws_account_id.dkr.ecr.us-east-1.amazonaws.com

You will need the following credentials: 1. AWS Source Registry Url - This is the URL of the source registry, typically in the format of aws_account_id.dkr.ecr.us-east-1.amazonaws.com 2. AWS Authentication Token - This is the token generated by the AWS CLI tool using the commands from above. 3. JFrog Username - This can be found under your profile on JFrog under "Edit Profile". 4. JFrog Password or API Token - Make sure you have a valid personal access token with the necessary permissions. Good practice will be to add a task to the script that allows you to connect to Azure Key Vault so you can avoid having the secret values in plain text in the script.

Lastly, you will need to authenticate with Azure DevOps using your pat token. See the code example below:

$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$pat"))

Setting up the Image Files Format

To specify which images and tags are migrated, you will need to set up a text file with a newline-deliminted list of images.

examplebox examplebox/1.0 examplebox/latest

The specification of examplebox without tags will migrate all tags, but specifying a tag such as the case of 1.0 or latest will migrate only what is needed,

Migrating to Artifactory

To migrate a registry image from ECR to Artifactory, run the python script with the following command:

python2 DockerMigrator.py ecr -v https://aws_account_id.dkr.ecr.us-east-1.amazonaws.com AWS_TOOL_TOKEN https://mdtprod.jfrog.io/artifactory JFROG_USERNAME JFROG_API_TOKEN crmsand-docker-local --ignore-certs --image-file PATH/TO/IMAGEFILE --ignore-certs -v