kaniko equivalent of -tag

110 views
Skip to first unread message

Darrel Cusey

unread,
May 10, 2021, 6:25:06 PM5/10/21
to kaniko-users
I'm trying to switch from dind, and I can build images with kaniko successfully, but there doesn't seem to be a way to tag the image, so future docker tag/push commands fail.

What I used to do:

- docker build --no-cache -t $CONTAINER_IMAGE:latest  .

What I'm doing now (standard for Kaniko in GitLab CI):

image:
  entrypoint: [""]
script:
  - mkdir -p /kaniko/.docker
  - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
  - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CONTAINER_IMAGE:latest

This works...

INFO[0182] Pushed image to 1 destinations
Job succeeded

...but the image that Kaniko builds doesn't seem to actually get tagged.  

The reason this is a problem is that in a later step, when I want to do this (publish to Google Container Registry in this case):

- docker tag $CONTAINER_IMAGE:latest $GCR_CONTAINER_IMAGE:$CI_COMMIT_TAG
- docker push $GCR_CONTAINER_IMAGE:$CI_COMMIT_TAG

...I get the error that the image doesn't exit...

Error response from daemon: No such image
ERROR: Job failed: exit code 1

...so, how do I actually tag my image with Kaniko so that I can access it in later steps through standard docker tag/push commands?








Laurent Philippart

unread,
Jun 15, 2021, 2:51:19 PM6/15/21
to kaniko-users
I have a similar need for a --tag ghcr.io/TARGET_OWNER/TARGET_IMAGE_NAME:VERSION option whereby I would be able to tag an image as required before pushing it to the Github Container Registry.

Since this will be running within a Tekton Pipeline, I could separate the build and the tag + push tasks using kaniko to build without push and then something else TBD for the tag & push. What would be your suggestion for the tag & push commands without relying on docker?

Thanks in advance for your feedback.
Laurent
Reply all
Reply to author
Forward
0 new messages