0

according to docs for pulling from and pushing to a local registry, you have to tag an image like this :

docker image tag rhel-httpd:latest registry-host:5000/myadmin/rhel-httpd:latest
docker image push registry-host:5000/myadmin/rhel-httpd:latest

right now I have a lot of deployments and helm charts in my on-prem k8s cluster and it's not really convenient to rename all the reference images every time our registry address changes. is there any way to change the default registry without tagging the images?

i'm using registry:2 image to run a local docker registry with docker compose like this:

version: "3"
services:
  registry:
      image: registry:2
      ports:
        - 5000:5000
      environment:
        - REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /data
      restart: unless-stopped
      volumes:
        - ./data:/data
aSaffary
  • 793
  • 9
  • 22
  • instead of re-tagging your images, make DNS record for registry – rkosegi Sep 30 '21 at 09:42
  • @rkosegi can you clarify a little more? how can I do that? is there an article or document you can refer me to? – aSaffary Sep 30 '21 at 10:27
  • 3
    You may find it useful to make the registry address a Helm parameter, even if your images are normally on Docker Hub (`docker.io`). Then if your registry's DNS name does change you can redeploy your charts with the new registry location. – David Maze Sep 30 '21 at 10:33
  • 2
    [How to change the default docker registry from docker.io to my private registry?](https://stackoverflow.com/questions/33054369/how-to-change-the-default-docker-registry-from-docker-io-to-my-private-registry) discusses this for the pure-Docker case, but the short answer is that you really want `ubuntu` to always mean `docker.io/library/ubuntu` and not `badguy.example.com/library/ubuntu` independent of the system configuration. – David Maze Sep 30 '21 at 10:35
  • Hi @aSaffary, did you try David Maze's solution to use a Helm parameter? – Mikolaj S. Oct 01 '21 at 10:18
  • @MikolajS. yes apparently (and unfortunately) that's the cleanest way possible. – aSaffary Oct 02 '21 at 02:54

1 Answers1

2

so as David Maze suggested and as it's been discussed in this answer and this issue it's best that we don't change the default registry. I ended up using a parameter inside my helm chart's values.yaml file. just an example of how it could be done :

#values.yaml
docker_registry: my.local.registry/
image_name: my_image_name

and then in any template that's addressing the image use {{ .Values.docker_registry}}{{ .Values.image_name}} instead of {{ .Values.image_name}}

we can also use the default registry by setting docker_registry : docker.io/

aSaffary
  • 793
  • 9
  • 22