skaffold: skaffold build w/ kaniko fails to push image to Docker Hub

Expected behavior

skaffold build w/ kaniko successfully pushes images to Docker Hub.

Actual behavior

skaffold build w/ kaniko fails to push image to Docker Hub.

skaffold build
Generating tags...
 - okepy/skaffold-example -> okepy/skaffold-example:v1.0.0-119-g2543e76d-dirty
Checking cache...
 - okepy/skaffold-example: Not found. Building
Creating docker config secret [docker-cfg]...
Building [okepy/skaffold-example]...
Storing build context at /var/folders/jn/6z4rmbv96wbgcpd7y4k1r7y00000gn/T/context-982e4adabe73af55eafdca0c5308aee2.tar.gz
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 "index.docker.io/okepy/skaffold-example:v1.0.0-119-g2543e76d-dirty": creating push check transport for index.docker.io failed: Get https://auth.docker.io/token?scope=repository%3Aokepy%2Fskaffold-example%3Apush%2Cpull&service=registry.docker.io: invoking docker-credential-desktop: exec: "docker-credential-desktop": executable file not found in $PATH; output: 
FATA[0014] build failed: build failed: building [okepy/skaffold-example]: kaniko build for [okepy/skaffold-example]: waiting for pod to complete: condition error: pod already in terminal phase: Failed 

Information

  • Skaffold version: v1.0.1
  • Operating system: macOS Catalina 10.15.1
  • Contents of skaffold.yaml:
apiVersion: skaffold/v1
kind: Config
build:
  artifacts:
    - image: okepy/skaffold-example
      kaniko:
        buildContext:
          localDir: {}
        cache: {}
  cluster:
    namespace: default
    dockerConfig:
      # specify path or secretName
      path: ~/.docker/config.json
      # secretName: docker-cfg
deploy:
  kubectl:
    manifests:
      - k8s-*

~/.docker/config.json

{
  "stackOrchestrator" : "swarm",
  "auths" : {
    "https://index.docker.io/v1/" : {
      "auth": "base64 decoded USER:PASSWORD"
    },
  },
  "credHelpers" : {
    "us.gcr.io" : "gcloud",
    "asia.gcr.io" : "gcloud",
    "staging-k8s.gcr.io" : "gcloud",
    "marketplace.gcr.io" : "gcloud",
    "gcr.io" : "gcloud",
    "eu.gcr.io" : "gcloud"
  },
  "credsStore" : "desktop",
  "experimental" : "disabled",
  "HttpHeaders" : {
    "User-Agent" : "Docker-Client/19.03.4 (darwin)"
  }
}

Steps to reproduce the behavior

  1. https://github.com/GoogleContainerTools/skaffold/tree/master/examples/kaniko-local
  2. edit skaffold.yaml
  3. skaffold build

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 18 (8 by maintainers)

Most upvoted comments

I finally make it works:

apiVersion: skaffold/v2alpha3
kind: Config
metadata:
  name: super-random
build:
  artifacts:
  - image: saphoooo/super-random # dockerhub repo
    kaniko:
      cache:
        repo: saphoooo/super-random # dockerhub repo
  cluster:
    pullSecretName: regcred
    namespace: default
    dockerConfig:
      secretName: skaffold-cfg
deploy:
  kubectl:
    manifests:
    - super-deployment.yaml

I created the secret this way:

$ kubectl create secret generic skaffold-cfg \
    --from-file=config.json
$ kubectl label secret skaffold-cfg skaffold-kaniko=skaffold-kaniko

I hope it helps.

I ran into the same error and as the information here is a bit scattered around I will summarize the steps here.

  1. Create proper credentials for your container registry. Example user123 / pass123
  2. Create an auth string for your config.json: echo "user123: pass123" | base64
  3. Create config.json as below
  4. Create secret for dockerConfig: kubectl create secret generic skaffold-cfg --from-file=config.json
  5. Label secret. Not sure if necessary: kubectl label secret skaffold-cfg skaffold-kaniko=skaffold-kaniko
  6. Create pullSecret: kubectl create secret generic regcred --from-file=.dockerconfigjson=./config.json --type=kubernetes.io/dockerconfigjson
  7. The below given skaffold.yaml should now work

config.json

{
    "auths": {
            "yourContainerReg": {
                    "auth": "dXNlcjEyMzogcGFzczEyMwo="
            }
    }
}

skaffold.yaml

        pullSecretName: regcred
        dockerConfig:
           secretName: skaffold-cfg

I ran through the same issue, but:

It’s working with path:

  cluster:
    pullSecretName: regcred
    dockerConfig:
      path: ./config.json

The config.json file is in the same directory than skaffold.yaml

It’s still not working with secretName, even if I followed what is documented in the code:

// DockerConfig contains information about the docker `config.json` to mount.
type DockerConfig struct {
	// Path is the path to the docker `config.json`.
	Path string `yaml:"path,omitempty"`

	// SecretName is the Kubernetes secret that contains the `config.json` Docker configuration.
	// Note that the expected secret type is not 'kubernetes.io/dockerconfigjson' but 'Opaque'.
	SecretName string `yaml:"secretName,omitempty"`
}
  cluster:
    pullSecretName: regcred
    dockerConfig:
      secretName: dockerreg
$ k get secret
NAME                  TYPE                                  DATA   AGE
dockerreg             Opaque                                1      4m58s
regcred               kubernetes.io/dockerconfigjson        1      50m
k describe secret dockerreg
Name:         dockerreg
Namespace:    default
Labels:       <none>
Annotations:  <none>

Type:  Opaque

Data
====
config.json:  127 bytes