Welcome to the Linux Foundation Forum!

Kaniko executor couldn't push the image into the container registry

In Lab 4 Page 9, mentioned Kaniko excutor as

  1. stage('Docker BnP') {
  2. steps {
  3. container('kaniko') {
  4. sh '/kaniko/executor -f `pwd`/Dockerfile -c `pwd`
  5. --insecure --skip-tls-verify --cache=true
  6. --destination=docker.io/xxxxxx/dsodemo'
  7. }
  8. }
  9. }

As the docker.io doesn't exists, I have changed it into.

sh '/kaniko/executor -fpwd/Dockerfile -cpwd--insecure --skip-tls-verify --cache=true --destination=https://hub.docker.com/r/baladevsecops/dso:latest'

I am getting the below error, Could you please help me to resolve this issue?

  1. + /kaniko/executor -f /home/jenkins/agent/workspace/dso_main/Dockerfile -c /home/jenkins/agent/workspace/dso_main --insecure --skip-tls-verify '--cache=true' '--destination=https://hub.docker.com/r/baladevsecops/dso:latest'
  2. error checking push permissions -- make sure you entered the correct tag name, and that you are authenticated correctly, and try again: checking push permission for "https://hub.docker.com/r/baladevsecops/dso:latest": creating push check transport for https: failed: Get "https://https/v2/": dial tcp: lookup https on 10.68.0.10:53: no such host; Get "http://https/v2/": dial tcp: lookup https on 10.68.0.10:53: no such host

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Comments

  • When I tried with sh '/kaniko/executor -fpwd/Dockerfile -cpwd--insecure --skip-tls-verify --cache=true --destination=docker.io/baladevsecops/dso' got the below error

    1. + /kaniko/executor -f /home/jenkins/agent/workspace/dso_main/Dockerfile -c /home/jenkins/agent/workspace/dso_main --insecure --skip-tls-verify '--cache=true' '--destination=docker.io/baladevsecops/dso'
    2. error checking push permissions -- make sure you entered the correct tag name, and that you are authenticated correctly, and try again: checking push permission for "docker.io/baladevsecops/dso": POST https://index.docker.io/v2/baladevsecops/dso/blobs/uploads/: UNAUTHORIZED: authentication required; [map[Action:pull Class: Name:baladevsecops/dso Type:repository] map[Action:push Class: Name:baladevsecops/dso Type:repository]]
  • @gbalamurugan check your kaniko specs in your build-agent.yaml. I simplified it to:

    1. - name: kaniko
    2. image: gcr.io/kaniko-project/executor:debug
    3. imagePullPolicy: Always
    4. command:
    5. - sleep
    6. args:
    7. - 99d
    8. volumeMounts:
    9. - name: jenkins-docker-cfg
    10. mountPath: /kaniko/.docker

    and under volumes

    1. - name: jenkins-docker-cfg
    2. secret:
    3. secretName: regcred
    4. items:
    5. - key: .dockerconfigjson
    6. path: config.json

    In Jenkinsfile the stage looks like this:

    1. stage('Docker BnP') {
    2. steps {
    3. container('kaniko') {
    4. sh '''
    5. /kaniko/executor --verbosity debug -f `pwd`/Dockerfile -c `pwd` --insecure --skip-tls-verify --cache=true --destination=docker.io/fingolfint/dsodemo:latest
    6. '''
    7. }
    8. }
    9. }
  • According to this issue (https://github.com/GoogleContainerTools/kaniko/issues/1542), you have to declare below environment variable as part of Kaniko pod declaration in your build-agent.yaml:
    env:
    -name: container
    value: kube

  • Posts: 1
    edited October 2023

    I Found that for newer version, you should mount credential volumes as the following:

    1. - name: jenkins-docker-cfg
    2. secret:
    3. secretName: regcred
    4. items:
    5. - key: .dockerconfigjson
    6. path: config.json
  • @soundwave said:
    I Found that for newer version, you should mount credential volumes as the following:

    1. - name: jenkins-docker-cfg
    2. secret:
    3. secretName: regcred
    4. items:
    5. - key: .dockerconfigjson
    6. path: config.json

    Can you provide the reference, this solved my 2 weeks problems pushing to my private repo. Thanks so much

  • Posts: 22

    I this still valid?
    I can't make it work even applying the suggested solution above.

    1. kubectl create secret -n ci docker-registry regcred--docker-server=https://index.docker.io/v1/--docker-username=xxxxxx --docker-password=yyyyyy--docker-email=xyz@abc.org
  • Posts: 1
    edited January 28

    This worked for me by combining the suggestions above. I want to post it here, should anyone encounter the issue in the future.

    In the build-agent.yaml file,

    1. - name: kaniko
    2. image: gcr.io/kaniko-project/executor:v1.6.0-debug
    3. imagePullPolicy: Always
    4. env:
    5. - name: container
    6. value: kube
    7. command:
    8. - sleep
    9. args:
    10. - 99d
    11. volumeMounts:
    12. - name: jenkins-docker-cfg
    13. mountPath: /kaniko/.docker

    Under volumes:

    1. - name: jenkins-docker-cfg
    2. secret:
    3. secretName: regcred
    4. items:
    5. - key: .dockerconfigjson
    6. path: config.json

    Finally for the jenkinsfile:

    1. stage('OCI Image BnP') {
    2. steps {
    3. container('kaniko') {
    4. sh '''
    5. /kaniko/executor --verbosity debug -f `pwd`/Dockerfile -c `pwd` --insecure --skip-tls-verify --cache=true --destination=docker.io/<username>/dsodemo:latest
    6. '''
    7. }
    8. }
    9. }
    10.  

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training