Fatskills
Practice. Master. Repeat.
Study Guide: Docker: Registry and Repository - Private Registries, AWS ECR, Azure ACR, Google GAR, JFrog Artifactory, Harbor
Source: https://www.fatskills.com/kubernetes/chapter/docker-docker-registry-and-repository-private-registries-aws-ecr-azure-acr-google-gar-jfrog-artifactory-harbor

Docker: Registry and Repository - Private Registries, AWS ECR, Azure ACR, Google GAR, JFrog Artifactory, Harbor

By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.

⏱️ ~5 min read

1. Core Command / Concept

Create a private Docker registry for secure image storage and sharing. docker login

2. Step-by-Step (numbered)

  1. Create an AWS ECR repository:
  2. Check if AWS CLI is installed: aws --version
  3. Create a repository: aws ecr create-repository --repository-name my-repo
  4. Get the repository URL: aws ecr describe-repositories --repository-names my-repo --query 'repositories[0].repositoryUrl' --output text
  5. Output: https://123456789012.dkr.ecr.<region>.amazonaws.com/my-repo
  6. Push an image to AWS ECR:
  7. Tag the image: docker tag my-image:latest 123456789012.dkr.ecr.<region>.amazonaws.com/my-repo/my-image:latest
  8. Login to ECR: aws ecr get-login-password --region <region> | docker login --username AWS --password-stdin 123456789012.dkr.ecr.<region>.amazonaws.com
  9. Push the image: docker push 123456789012.dkr.ecr.<region>.amazonaws.com/my-repo/my-image:latest
  10. Create an Azure ACR repository:
  11. Check if Azure CLI is installed: az --version
  12. Create a repository: az acr repository create --name my-repo --resource-group my-group --subscription <subscription>
  13. Get the repository URL: az acr repository show --name my-repo --resource-group my-group --query 'registry.loginServer' --output tsv
  14. Output: <registry_name>.azurecr.io
  15. Push an image to Azure ACR:
  16. Tag the image: docker tag my-image:latest <registry_name>.azurecr.io/my-repo/my-image:latest
  17. Login to ACR: az acr login --name <registry_name>
  18. Push the image: docker push <registry_name>.azurecr.io/my-repo/my-image:latest
  19. Create a Google GCR repository:
  20. Check if gcloud CLI is installed: gcloud --version
  21. Create a repository: gcloud container repositories create my-repo --project <project>
  22. Get the repository URL: gcloud container repositories describe my-repo --project <project> --format='get(url)'
  23. Output: <project>.crc.io/my-repo
  24. Push an image to Google GCR:
  25. Tag the image: docker tag my-image:latest <project>.crc.io/my-repo/my-image:latest
  26. Login to GCR: gcloud auth configure-docker
  27. Push the image: docker push <project>.crc.io/my-repo/my-image:latest
  28. Create a JFrog Artifactory repository:
  29. Check if Artifactory CLI is installed: art --version
  30. Create a repository: art if r --create --url <url> --username <username> --password <password> my-repo
  31. Get the repository URL: art if r --url <url> --username <username> --password <password> --query 'my-repo.url' --output text
  32. Output: <url>/my-repo
  33. Push an image to JFrog Artifactory:
  34. Tag the image: docker tag my-image:latest <url>/my-repo/my-image:latest
  35. Login to Artifactory: art if r --url <url> --username <username> --password <password> --login
  36. Push the image: docker push <url>/my-repo/my-image:latest
  37. Create a Harbor repository:
  38. Check if Harbor CLI is installed: harbor --version
  39. Create a repository: harbor registry create --name my-repo --username <username> --password <password> --url <url>
  40. Get the repository URL: harbor registry describe --name my-repo --username <username> --password <password> --query 'my-repo.url' --output text
  41. Output: <url>/my-repo
  42. Push an image to Harbor:
    • Tag the image: docker tag my-image:latest <url>/my-repo/my-image:latest
    • Login to Harbor: harbor registry login --username <username> --password <password> --url <url>
    • Push the image: docker push <url>/my-repo/my-image:latest

3. Real Commands with Examples

AWS ECR

  • Purpose: Push an image to AWS ECR
  • Command: aws ecr get-login-password --region <region> | docker login --username AWS --password-stdin 123456789012.dkr.ecr.<region>.amazonaws.com
  • Flags: --region specifies the AWS region, --username specifies the AWS username, and --password-stdin specifies the password from the AWS CLI.

Azure ACR

  • Purpose: Push an image to Azure ACR
  • Command: az acr login --name <registry_name>
  • Flags: --name specifies the Azure ACR registry name.

Google GCR

  • Purpose: Push an image to Google GCR
  • Command: gcloud auth configure-docker
  • Flags: None.

JFrog Artifactory

  • Purpose: Push an image to JFrog Artifactory
  • Command: art if r --url <url> --username <username> --password <password> --login
  • Flags: --url specifies the Artifactory URL, --username specifies the Artifactory username, and --password specifies the Artifactory password.

Harbor

  • Purpose: Push an image to Harbor
  • Command: harbor registry login --username <username> --password <password> --url <url>
  • Flags: --username specifies the Harbor username, --password specifies the Harbor password, and --url specifies the Harbor URL.

4. Common Errors

Error 1: Unable to push image to registry

  • Error Message: Error response from daemon: Get https://...: dial tcp: i/o timeout
  • Why it happens: The registry is not accessible or the image is too large.
  • Fix: Check the registry URL and try pushing the image again.

Error 2: Unable to login to registry

  • Error Message: Error response from daemon: Get https://...: unauthorized
  • Why it happens: The username or password is incorrect.
  • Fix: Check the username and password and try logging in again.

Error 3: Unable to create repository

  • Error Message: Error: unable to create repository
  • Why it happens: The repository name is already taken.
  • Fix: Try creating a different repository name.

5. Quick Checks

Situation 1: Unable to push image to registry

  • Command to run: docker push <registry_url>/my-repo/my-image:latest
  • Correct response: The image is pushed successfully.

Situation 2: Unable to login to registry

  • Command to run: docker login <registry_url>
  • Correct response: The login is successful.

Situation 3: Unable to create repository

  • Command to run: aws ecr create-repository --repository-name my-repo
  • Correct response: The repository is created successfully.

6. Last-Minute Reference

  • AWS ECR: aws ecr get-login-password requires Docker 20.10 or later.
  • Azure ACR: az acr login requires Azure CLI 2.0 or later.
  • Google GCR: gcloud auth configure-docker requires gcloud CLI 291.0.0 or later.
  • JFrog Artifactory: art if r requires Artifactory CLI 2.0 or later.
  • Harbor: harbor registry login requires Harbor CLI 1.0 or later.
  • Never push sensitive data to a public registry.
  • Always use a secure connection to the registry.
  • Use a unique username and password for each registry.
  • Regularly update your Docker and registry clients.