Skip to content

setup container image registry

devonfw-core edited this page Dec 27, 2022 · 5 revisions

Setup Container Image Registry

The scope of this section is to setup/create a container image registry or repository (depending on provider) on Docker Hub, AWS or Azure for allowing the pipeline that will package the application to push the resulting container image. By the end of this guide, we will get as an output the container repository URI, and, for some providers, the credentials for accessing the registry.

A container image name generically has the following format:

  • <registry-url>/<namespace>/<image-name>:<tag>

    • <registry-url>: Container registry URL based on registry provider.

    • <namespace>: Namespace within which the image is located.

    • <image-name>: Repository/image name which can be from one level to n-level deep (depending on provider).

    • <tag>: Some alphanumeric tag which is given as identifier.

Docker Hub

Prerequisites

  • Docker Hub account is required to access Docker Hub Registry. You can create one here.

Creating an image repository

  • Login on Docker Hub website.

  • Go to Repositories tab and click on "Create Repository".

  • Provide Name and Visibility for the repository and click "Create" button.

Image Format

Note
For referencing an image in Docker Hub, you don’t have to specify the <registry-url> since it is the default on Docker. IMPORTANT: Docker Hub does not support multi-level image names.
  • <namespace>/<image-name>:<tag>

    • <namespace>: Username or Organization on Docker Hub.

    • <image-name>: Previously chosen repository name.

    • <tag>: Some alphanumeric tag which is given as identifier.

Examples

  • devonfw/my-thai-star-angular:latest

  • devonfw/my-thai-star-java:1.5

  • devonfw/devon4quarkus-reference:2.0

AWS Elastic Container Registry

Prerequisites

  • An AWS account.

  • AWS CLI installed.

Creating an image repository namespace

  • Get the AWS Account ID by executing aws sts get-caller-identity.

  • Login to AWS ECR with the following command (an example <region> would be eu-west-1):

   aws ecr get-login-password \
       --region <region> | docker login \
       --username AWS \
       --password-stdin <aws-account-id>.dkr.ecr.<region>.amazonaws.com
  • Create a repository namespace with the following command:

   aws ecr create-repository \
       --repository-name <namespace> \
       --region <region>

Sample Output

   {
       "repository": {
           "registryId": "123456789012",
           "repositoryName": "sample-repo",
           "repositoryArn": "arn:aws:ecr:eu-west-1:123456789012:repository/project-a/nginx-web-app"
       }
   }

Image Format

  • <registry-url>/<namespace>/<image-name>:<tag>

    • <registry-url>: <aws-account-id>.dkr.ecr.<region>.amazonaws.com

    • <namespace>: Previously chosen repository name.

    • <image-name>: Freely chosen project/image-name given by the user.

    • <tag>: Some alphanumeric tag which is given as identifier.

That is:

  • <aws-account-id>.dkr.ecr.<region>.amazonaws.com/<repository-name>/<image-name>:<tag>

Examples

  • 1000000001.dkr.ecr.eu-west-1.amazonaws.com/devonfw/my-thai-star-angular:latest

  • 1000100001.dkr.ecr.us-east-1.amazonaws.com/devonfw/my-thai-star/angular:1.5

  • 1000200001.dkr.ecr.ap-south-1.amazonaws.com/devonfw/quarkus/sample/devon4quarkus-reference:2.0

Azure Container Registry

Prerequisites

  • An Azure account with active subscription.

  • An Azure resource group.

  • Azure CLI installed.

Creating an image registry

  • Login to Azure using az login.

  • Set the Azure Subscription using az account set --subscription <mySubscription>.

  • Create a registry with the following command:

   az acr create --resource-group <resourcegroup-name> --name <registry-name> --sku Basic

Sample Output

{
  "adminUserEnabled": false,
  "creationDate": "2019-01-08T22:32:13.175925+00:00",
  "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myContainerRegistry007",
  "location": "eastus",
  "loginServer": "mycontainerregistry007.azurecr.io",
  "name": "myContainerRegistry007",
  "provisioningState": "Succeeded",
  "resourceGroup": "myResourceGroup",
  "sku": {
    "name": "Basic",
    "tier": "Basic"
  },
  "status": null,
  "storageAccount": null,
  "tags": {},
  "type": "Microsoft.ContainerRegistry/registries"
}
  • Enable user and password authentication on the registry with the following command:

Note
Any authentication option that produces as a result a long-term user and password is valid. The least troublesome one follows.
   az acr update -n <registry-name> --admin-enabled true
  • Retrieve credentials for accessing the registry with the following command:

   az acr credential show --name <registry-name>

Image Format

  • <registry-url>/<namespace>/<image-name>:<tag>

    • <registry-url>: <registry-name>.azurecr.io

    • <namespace>/<image-name>: Freely chosen project/image-name given by the user.

    • <tag>: Some alphanumeric tag which is given as identifier.

That is:

  • <registry-name>.azurecr.io/<namespace>/<image-name>:<tag>

Examples

  • devonacr.azurecr.io/devonfw/my-thai-star-angular:latest

  • devonacr.azurecr.io/devonfw/my-thai-star/angular:1.5

  • devonacr.azurecr.io/devonfw/quarkus/sample/devon4quarkus-reference:2.0

Google Cloud Artifact Registry

Prerequisites

  • A Google Cloud project already setup

  • Artifact Repository API enabled for the project

  • GCloud CLI installed and configured

Creating an Artifact Registry image repository

  • Login to GCloud using gcloud auth login.

  • Create a container image repository with the following command:

   gcloud artifacts repositories create <repository-name> --repository-format=docker --location=<repository-location>

Sample Output

Create request issued for: [testdockerrepo]
Waiting for operation [projects/poc-cloudnative-capgemini/locations/europe-southwest1/operations/748b5502-43af-46b9-9f3
a-eb2f5bd4178c] to complete...done.
Created repository [testdockerrepo].
  • Enable access to your Artifact Registry repository from your local Docker client using:

gcloud auth configure-docker <location>-docker.pkg.dev

Sample Output

Adding credentials for: europe-west9-docker.pkg.dev
After update, the following will be written to your Docker config file located at
[C:\Users\mcerverc\.docker\config.json]:
 {
  "credHelpers": {
    "europe-west9-docker.pkg.dev": "gcloud"
  }
}

Image Format

  • <location>-docker.pkg.dev/<project-id>/<repository>/<image-name>:<tag>

    • <location>: Regional or multi-regional location of the repository.

    • <project-id>: Google Cloud project ID.

    • <repository>: Previously chosen repository name.

    • <image-name>: Freely chosen project/image-name given by the user.

    • <tag>: Some alphanumeric tag which is given as identifier.

Examples

  • europe-southwest1-docker.pkg.dev/poc-cloudnative-capgemini/testdockerrepo/imagendetest:v1

  • us-east5-docker.pkg.dev/projecttest/repo123/helloworld:latest

Provider Documentation

Guides per provider

Clone this wiki locally