Skip to content

Pull Docker images from CloudRepo

The Docker CLI reads CloudRepo like any other registry: log in once, then pull by the image’s full name. This page is for the person whose machine or pipeline pulls images from a repository. To put images there, see Publish Docker images.

You need a Docker repository and a repository token that reaches it. If you have neither yet: create a repository and create a token. A token that has Download packages access is enough to pull.

Used on this page only, never saved. Never enter a token or password here.

Log in to your organization’s host, with your email address and the token. Pipe the token to docker login on standard input.

Terminal
echo "$CLOUDREPO_TOKEN" | docker login your-org.mycloudrepo.io \
--username you@example.com \
--password-stdin

Expected: Login Succeeded.

  • The password is the repository token. Create one on the Repository Tokens page of the admin portal.
  • Log in to the host alone, your-org.mycloudrepo.io, with no path. Docker stores the credential by host and discards any path you add.
  • CloudRepo does not check the username, so any value works, but use your email address.

The image name includes the repository after a literal /repositories/:

Terminal
docker pull your-org.mycloudrepo.io/repositories/your-repo/my-app:1.0.0

The name is <organization>.mycloudrepo.io/repositories/<repository>/<image>:<tag>. You logged in to the bare host, but you pull from the /repositories/ path, and the login names no repository, so a good login tells you nothing about whether the name is right.

Expected: Docker prints Status: Downloaded newer image for the name you pulled.

Use the same login, with the token from your CI’s secret store:

Terminal
echo "$CLOUDREPO_TOKEN" | docker login your-org.mycloudrepo.io --username you@example.com --password-stdin

Store the token as a secret (a GitHub Actions secret, a GitLab CI variable) and never commit it. The name is yours to choose: the admin portal’s ready-made GitHub Actions and GitLab CI snippets call it CLOUDREPO_PASSWORD, after Docker’s password field. The value is the same repository token, not a CloudRepo password.

When a docker build installs private packages from CloudRepo, pass the token as a build secret, never as a build argument. Docker records build arguments in the image’s history. The Docker repositories page shows how for Maven, pip and npm.

A pod pulls with the same login as docker pull: your email address and a repository token with access to the repository. Kubernetes keeps the login in a Secret of type kubernetes.io/dockerconfigjson, and a pod names the Secret under imagePullSecrets. Use a token with Download packages access: the Secret holds the token, and anyone who can create a pod in its namespace can read it.

The Secret holds a Docker config.json. Create that file with docker login in its own directory, so it contains this one login and none of your other registries. Pipe the token to docker login on standard input.

Terminal
export DOCKER_CONFIG="$(mktemp -d)"
printf '%s' '{"auths":{"your-org.mycloudrepo.io":{}}}' > "$DOCKER_CONFIG/config.json"
printf '%s' "$CLOUDREPO_TOKEN" | docker login your-org.mycloudrepo.io --username you@example.com --password-stdin

Expected: Login Succeeded. Docker may also print a warning that it keeps the credentials in config.json. It does, until the rm command below removes the directory.

The second line of that block matters. Docker sends a login to the platform’s default credential helper when that helper is installed, and Docker Desktop installs one. The login then never reaches config.json: the file holds a credsStore line and an empty entry for the host, and no auth entry, as Kubernetes’ guide describes for a credentials store. With Docker 29.7.2, a config.json that already lists the host makes Docker write the login into the file. The next block starts by checking it. Its first two lines are one command: grep looks for an auth entry, and kubectl runs only if it finds one. If the file has none, because the login failed or because Docker used a helper, no Secret is made, and a Secret made from that file would hold no login. For a helper, Kubernetes’ guide lists other ways to create the Secret; the one it shows for a registry login, kubectl create secret docker-registry, takes the token as a command-line argument.

Create the Secret from the file if the login is in it. The last two lines remove the directory whether or not the Secret was made:

Terminal
grep -q '"auth"' "$DOCKER_CONFIG/config.json" \
&& kubectl create secret generic cloudrepo \
--type=kubernetes.io/dockerconfigjson \
--from-file=.dockerconfigjson="$DOCKER_CONFIG/config.json"
rm -r "$DOCKER_CONFIG"
unset DOCKER_CONFIG

Create the Secret in the namespace where the pod runs: add --namespace and the namespace’s name to the kubectl create secret command. A pod can only use a Secret in its own namespace.

image is the name docker pull takes, with the literal repositories/ segment, as under Pull an image. imagePullSecrets names the Secret.

pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: my-app
spec:
containers:
- name: my-app
image: your-org.mycloudrepo.io/repositories/your-repo/my-app:1.0.0
imagePullSecrets:
- name: cloudrepo

In a Deployment, the same list goes in the Pod template, under spec.template.spec.

Use the secret for every pod in a namespace

Section titled “Use the secret for every pod in a namespace”

Add the Secret to the namespace’s default ServiceAccount, and a pod does not list it:

Terminal
kubectl patch serviceaccount default --patch '{"imagePullSecrets": [{"name": "cloudrepo"}]}'

A new pod in that namespace that uses the default ServiceAccount has its spec.imagePullSecrets set automatically.

A pod that cannot pull shows ErrImagePull, then ImagePullBackOff while Kubernetes keeps trying with a growing delay. What it shows depends on your container runtime. The pod’s events say why: kubectl describe pod with the pod’s name lists them. Match what they say to a row:

The pod’s events show What it means What to do
FailedToRetrieveImagePullSecret Kubernetes cannot find a Secret with that name in the pod’s namespace. Check the name against imagePullSecrets, and create the Secret in the pod’s namespace. If the Secret block made none, its check found no login in config.json: run the commands again from the top.
401 Unauthorized The registry did not accept the login: the token was revoked or has expired. Create a token as under When Docker answers 401, 403 or 404, and make the Secret again.
403 or denied The token does not reach this repository. Use a token that includes it, as under When Docker answers 401, 403 or 404.
The repository or image is not found The name is wrong, or the image or tag does not exist. Check the repositories/ segment, the image and the tag, as under When Docker answers 401, 403 or 404.

See what a repository holds in the admin portal. The registry API does not list images: /v2/_catalog answers 405 UNSUPPORTED.

  • docker login answers 401 Unauthorized. Use a repository token as the password. Check on the Repository Tokens page that it has not been revoked or expired. A token from npm login (crn_v1_) works only on the npm repository it was created for, and Docker refuses it.
  • docker pull answers 403 or denied. The token does not have access to this repository. A token accesses only the repositories selected when it was created, so use one that includes this repository.
  • docker pull cannot find the repository or the image. Check that the name includes the literal repositories/ segment, as above, and that the image and tag exist in that repository.

More: Repository tokens, for every client’s credential; Proxy repositories, to pull Docker Hub or another registry through CloudRepo; Docker repositories, for pushing, groups and the other settings.

View as Markdown