If you are using private container registries, you must create a dockercfg.json file that contains the credentials to the registry. Then you must create a secret, which must be called snyk-monitor.
The dockercfg.json file is necessary to allow the monitor to look up images in private registries. Usually, your credentials are in $HOME/.docker/config.json. However, the credentials must also be added to the dockercfg.json file. The Snyk Controller is not able to access these registries if the credentials are only stored in $HOME/.docker/config.json
The steps below explain how to authenticate to private container registries.
Configure the dockercfg.json file
Create a file named dockercfg.json. Store your credentials in this file.
Ensure the file containing your credentials is named dockercfg.json. This filename is required by the snyk-monitor.
Ensure the formatting is correct, including new line characters and whitespace in the dockercfg.json file. Malformed files will result in authentication failures.
The locations where your cluster runs and where your registries run determine the combination of entries in your dockercfg.json file. The file can contain credentials for multiple registries.
If your credentials are already in $HOME/.docker/config.json, copy this information to the dockercfg.json file.
If the auth entry is empty in the $HOME/.docker/config.json, run the following command and paste the output to auth entry in dockercfg.json:
echo -n 'username:password' | base64
Examples of dockercfg.json file configuration
For private registries other than Nexus
If your cluster does not run on GKE, or it runs on GKE and pulls images from other private registries, yourdockercfg.json file must contain:
{ "auths": {"gcr.io": {"auth":"BASE64-ENCODED-AUTH-DETAILS" },// Add other registries as necessary, for example:"<yourdomain>.azurecr.io": {"auth":"BASE64-ENCODED-AUTH-DETAILS" } }}
For Nexus Repository
If you are using Nexus Repository**,** your dockercfg.json file must contain:
If your cluster runs on GKE and you are using GAR, yourdockercfg.json file must contain:
{"auths": {"northamerica-northeast2-docker.pkg.dev": {"auth":"<output from “echo -n _json_key_base64:BASE64-ENCODED-AUTH-DETAILS"} }}
This method relies on creating a service account. See Google Cloud service account key. Ensure you follow the optional steps to base64 encode the file.
The “auth” line is generated with the following command, where the username is json_key_base64 and the password is the entire contents of the base64 json keyfile.
echo-n'username:password'|base64
For example, the output of this command is used in the “auth” line of the dockercfg.json
In addition, for clusters running on AKS and using ACR, see Entra ID Workload Identity service account. It is possible that you are required to configure labels and annotations on the snyk-monitor ServiceAccount.
You can configure different credential helpers for different registries.
Create the Kubernetes secret
Create the secret in Kubernetes by running the following command: