ARTIFACTORY: How to proxy a private Google Container Registry (GCR)?
Artifactory allows us to proxy a Google Container Registry by configuring a remote repository pointing to the GCR endpoint. Google offers the https://gcr.io and https://eu.gcr.io endpoints, both can be proxied in Artifactory, according to the needed endpoint.
- First, create a Docker remote repository in Artifactory, and set the URL to point to https://gcr.io (or https://eu.gcr.io, depending on the need)
- In the Google Cloud Platform UI, navigate to IAM & Admin → Service Accounts → Choose your service account → navigate to the “Keys” tab of the chosen account:
Click on “ADD KEY”, then “Create a new key” and choose JSON. Save the downloaded JSON file in an accessible location. -
Navigate back to the remote repository configuration page in Artifactory, and set the credentials of the remote repository under the “Advanced tab” as follows: User: _json_key Password: The password will be the content of the previously downloaded JSON file. Copy the file’s content and paste it here
- Now, it is possible to use the created Docker remote repository. For this example, pulling a public image of busybox from the publicly available GCR repository:
To view the pull command, click on the image name in the list (busybox) and then on the 3-dot menu of the preferred tag (in this case - latest) to copy the full pull command.
- Next, in the copied pull command, we will need to copy the part after the hostname (“gcr.io”) and replace the host part with our Artifactory host and the remorse repository name in order to pull the image using Artifactory. For instance:
docker pull <Artifactory_host>/google-remote/google-containers/busybox:latest
- Upon a successful pull, the image will be available in Artifactory under the repository’s remote-cache:
Please note that images that are available under the gcr.io endpoint, will not necessarily be available under the eu.gcr.io endpoint. Therefore, before pulling an image, make sure it exists in the desired endpoint. In addition, make sure that the endpoint is accessible under the GCP project and that the user has sufficient permissions to pull from these endpoints directly.