2

I'm designing a GitLab CI pipeline to build a Docker image for a given service.

This is how (the relevant excerpt from) the Gitlab CI manifest looks like so far:

...

publish-docker-image:
  stage: publish
  dependencies:
    - assemble
  image:
    name: docker.tld.com/namespace/kaniko:latest # At work they offer a custom kaniko image
    entrypoint: [""]
  script:
    - mkdir --parents /kaniko/.docker/
    - mv $kaniko_config /kaniko/.docker/config.json # $kaniko_config is a file variable from GitLab CI
    - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination artifactory.tld.com/artifactory/docker-snapshot/organization/project/kaniko-test:0.1.0

The $kaniko_config file translates into this JSON:

{
  "auths": {
    "https://artifactory.tld.com/": {
      "username": "the_real_username",
      "password": "the_real_password"
    }
  }
}

Now every time I run the pipeline I get this output:

$ mkdir --parents /kaniko/.docker/
$ mv $kaniko_config /kaniko/.docker/config.json
$ cat /kaniko/.docker/config.json
{
  "auths": {
    "https://artifactory.tld.com/": {
      "username": "the_real_username",
      "password": "the_real_password"
    }
  }
}
$ /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination artifactory.tld.com/artifactory/docker-snapshot/organization/project/kaniko-test:0.1.0
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 "artifactory.tld.com/artifactory/docker-snapshot/organization/project/kaniko-test:0.1.0": creating push check transport for artifactory.tld.com failed: GET https://artifactory.tld.com/v2/: : Not Found
Cleaning up file based variables

What am I doing wrong here? Moreover, I don't know why the error message have https://artifactory.tld.com/v2/ (the /v2) on it since I'm not using anything like that.

x80486
  • 6,627
  • 5
  • 52
  • 111
  • It looks like you Docker registry is wrong. The `https://artifactory.tld.com/` should be replaced by the configured Artifactory Docker registry. It depends on your reverse proxy configuration and it should be the same as using for a `docker login ` command. You can view the docker registry by using the "Set Me Up" button: https://www.jfrog.com/confluence/display/JFROG/Docker+Registry#DockerRegistry-SetMeUp – yahavi May 27 '21 at 08:36
  • @yahavi, you were correct, the Docker registry URL was wrong. Feel free to post your comment as an answer. – x80486 May 27 '21 at 13:54
  • I posted the comment as an answer to anyone who encounters this issue in the future. – yahavi May 27 '21 at 16:08

1 Answers1

3

To anyone who encounters this issue in the future - the kaniko-config.json file should have the following structure:

{
  "auths": {
    "<artifactory-docker-registry>": {
      ...
    }
  }
}

The "artifactory-docker-registry" can be retrieved using the Set Me Up button in the JFrog platform UI.

yahavi
  • 5,149
  • 4
  • 23
  • 39