Does kubernetes support alternative repository when pull or applying a deployment?

4/23/2020

To minimize network problems, I created a local repository, mirroring Docker Hub. When applying a deployment, my local registry goes down. Is it possible to automatically change repository source to Docker Hub instead of my local repository? Applying then, redundancy.

Like:

...
containers:
- name: webserver
  image-1: registry.mydomain/nginx:latest
  image-2: nginx:latest
  imagePullPolicy: Always
...
-- Eduardo Arruda Pimentel
docker
kubernetes

1 Answer

4/23/2020

The kubernetes pod spec doesn't include the functionality to specify multiple container images, but the underlying container runtime can often be configured to do that.

Docker

When a specific prefix domain is not provided for an image, The docker.io registry is the first place Docker looks for an unscoped image. This is why docker pull mysql. Docker has a registry-mirrors setting to modify this behaviour.

In daemon.json add:

{
  "registry-mirrors": [ "something.local" ],
}

This will cause Docker to look for non scoped images on something.local first, then docker.io.

-- Matt
Source: StackOverflow