Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add possibility to give multiple registry mirrors via environment variable (KANIKO_REGISTRY_MIRROR) #3283

Open
tldev-de opened this issue Aug 9, 2024 · 1 comment

Comments

@tldev-de
Copy link

tldev-de commented Aug 9, 2024

Actual behavior
The flag --registry-mirror can be used multiple times to give multiple registry mirrors into the build process. Sadly, the corresponding environment variable KANIKO_REGISTRY_MIRROR accepts only one registry mirror. When I try to set multiple values via any separator, I get the following error:

WARN[0000] Failed to retrieve image alpine/curl from remapped registry docker-mirror01.extern.XXX dockerhub.intranet.XXX docker-mirror02.extern.XXX: unable to complete operation after 0 attempts, last error: parse "https://docker-mirror01.extern.XXX dockerhub.intranet.XXX docker-mirror02.extern.XXX/v2/": invalid character " " in host name. Will try with the next registry, or fallback to the original registry.

Obviously, the environment variable does not support multiple registry mirrors - see root.go:

if val, ok := os.LookupEnv("KANIKO_REGISTRY_MIRROR"); ok {

Expected behavior
It should be possible to add multiple registry mirrors by a separator, e.g. any char, that is not used in urls. In my opinion, a space would be a good choice.

Since this looks like a small change and I'm getting familiar with golang, I would love to implement this feature.

To Reproduce
Steps to reproduce the behavior:

  1. download the provided dockerfile
  2. run kaniko with multiple registry mirrors, e.g.:
docker run -it --rm -e "KANIKO_REGISTRY_MIRROR=docker-mirror01.extern.XXX dockerhub.intranet.XXX docker-mirror02.extern.XXX" -v `pwd`:/workspace gcr.io/kaniko-project/executor:latest --dockerfile=Dockerfile --destination=image --tarPath=/workspace/image.tar --no-push

Additional Information

  • Dockerfile
FROM alpine/curl
RUN curl https://github.com/docker-library/hello-world/raw/master/amd64/hello-world/hello -o /hello
CMD ["/hello"]
  • Build Context
    nothing needed
  • Kaniko Image (fully qualified with digest)
    any (gcr.io/kaniko-project/executor:latest)

Triage Notes for the Maintainers

Description Yes/No
Please check if this a new feature you are proposing
Please check if the build works in docker but not in kaniko
Please check if this error is seen when you use --cache flag
Please check if your dockerfile is a multistage dockerfile
tldev-de added a commit to tldev-de/kaniko that referenced this issue Aug 12, 2024
allow to set multiple registry mirrors by environment variable
@babs
Copy link
Contributor

babs commented Aug 13, 2024

Take a look at registry-map witch allows exactly that

See https://github.com/GoogleContainerTools/kaniko#flag---registry-map
index.docker.io=docker-io.mirrors.corp.net;index.docker.io=mirror.gcr.io;gcr.io=127.0.0.1 will try docker-io.mirrors.corp.net then mirror.gcr.io for index.docker.io and 127.0.0.1 for gcr.io

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants