We have problems setting up kaniko together with our GitLab Runner (11.3.1): we are not able to push our Docker builds to our private Azure Container Registry. We believe the issue is in the authentication process. After some debugging, we found that there is a flag for /kaniko/executor: --azure-container-registry-config. However, we are not able to find what file is expected, nor can we find any documentation on this specific flag. Could anyone point us into the right direction? Maybe post an example Azure container registry config file? We appreciate your time and effort. FYI building Docker images works fine, kaniko rocks.
Hey @kreeftd , we actually don't have any special support for Azure in the kaniko image (that flag is added by a dependency, and is meant to be hidden, but I guess that isn't actually working)
You could try mounting in the azure credential helper along with your credentials, which should work. If you want to add the credential helper to the kaniko image, PRs are welcome!
@kreeftd I'm pushing to an azure registry. Using GitLab's docs as an example, I'm doing the following
script:
- echo "{\"auths\":{\"$AZURE_REGISTRY\":{\"username\":\"$AZURE_REGISTRY_USER\",\"password\":\"$AZURE_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $AZURE_REGISTRY_IMAGE:$CI_COMMIT_SHA
Seems to be ok so far in testing
@priyawadhwa thank you for your comment.
@jon-walton thank you for your help. I have been relying on the same doc and code, but it seems like I keep running into the following error message.
error pushing image: failed to push to destination <azure registry>/<image name>:<commit tag>: Get https://http/v2/: dial tcp: lookup http on <ip address>:<port>: server misbehaving
It might have something to do with our Kubernetes cluster or GitLab instance. I believe the issue is not in kaniko as you confirmed it should work with said environment variables. Therefore closing issue.
So it turns out we did not setup our environment variables in GitLab correctly. For the Azure Container Registry you should not add http://. Thus, in the example of @jon-walton your environment variables would be similar to:
$AZURE_REGISTRY = 'example.azurecr.io'
$AZURE_REGISTRY_IMAGE = 'example.azurecr.io/example-image-name'
Also note that none of the environment variables in GitLab can be set to privileged. They will result in the following error: error building image: getting stage builder for stage 0: unexpected end of JSON input
I have trouble pushing to ACR:
sample Dockefile:
FROM ubuntu
RUN mkdir /something
sample script
docker run \
-v /pathto/docker_config.json:/root/.docker/config.json \
-v /pathto/myapp:/app \
gcr.io/kaniko-project/executor \
--dockerfile=Dockerfile \
--context=/app \
--destination=something.azurecr.io/bla \
--cache=true \
--verbosity debug
output:
INFO[0011] Pushing layer something.azurecr.io/bla/cache:6dde23a1e4752bf36228a640853e4c716795ef06e6e1ddb925be7f75203c6ea6 to cache now
WARN[0012] error uploading layer to cache: failed to push to destination something.azurecr.io/bla/cache:6dde23a1e4752bf36228a640853e4c716795ef06e6e1ddb925be7f75203c6ea6: unexpected end of JSON input
error pushing image: failed to push to destination something.azurecr.io/bla:latest: unexpected end of JSON input
Apparently -v /pathto/docker_config.json:/root/.docker/config.json should be
-v /pathto/docker_config.json:/kaniko/.docker/config.json
Hi @obeleh,
i still get the sam error when i do a run. I tried your fix but still the same error.
error uploading layer to cache: failed to push to destination something.azurecr.io/ttest/cache:072773118be11a007c3572601aa58b4865fea80752a7377da4cc23aeb87b06b3: unexpected end of JSON input