3

I'm trying to generate an image with the JIB and push this image with Docker on Gitlab CI, but I'm having trouble with it.

I know that JIB can push for the registry itself, but my company registry url is not following the right pattern for JIB.

This is my .gitlab-ci.yml

image: docker:latest
services:
  - docker:dind

stages:
  - build
  - docker

variables:
  QUARKUS_PORT: 8080

build_test:
  image: adoptopenjdk/openjdk15:jre-15.0.1_9-alpine
  stage: build
  script:
    - ./mvnw -Dquarkus.container-image.build=true clean package

docker:
  image:
  stage: docker
  script: docker push my_registry.example.com

There's the following output from the job:

[ERROR]     [error]: Build step io.quarkus.container.image.jib.deployment.JibProcessor#buildFromJar threw an exception: java.lang.RuntimeException: Unable to create container image
...
[ERROR] Caused by: java.util.concurrent.ExecutionException: java.io.IOException: Cannot run program "docker": error=2, No such file or directory
...
[ERROR] Caused by: java.io.IOException: Cannot run program "docker": error=2, No such file or directory
...
[ERROR] Caused by: java.io.IOException: error=2, No such file or directory
...
G. Falcão
  • 115
  • 2
  • 8
  • I see you are trying to push an image to a local Docker daemon (which doesn't seem to exist while running `mvnw`) only to push to `my_registry.example.com` later. You can have Quarkus directly push to your registry, which won't require Docker. See https://stackoverflow.com/q/63813368/1701388 Pushing directly without the Docker daemon roundtrip will significantly improve the performance. (Jib does a stellar job when directly pushing.) – Chanseok Oh Jan 13 '21 at 20:50
  • @ChanseokOh Thanks for your answer! Unfortunately in my case that doesn't work. When I tried to push to the official docker registry it worked well but my company's registry doesn't follow the URL pattern that JIB needs, and generates an error. In our case, we are going to generate and push the image from Dockerfile. – G. Falcão Jan 14 '21 at 03:43
  • 1
    I am sure you can make it work with your private registry. If you think the URL pattern is an issue, double-check [the Quarkus doc](https://quarkus.io/guides/container-image#quarkus-container-image_configuration) or get some help from the Quarkus folks. In any case, your original error is because you don't have the Docker client CLI command (the `docker` binary) on the `$PATH`. Whether it's because your Docker setup on GitLab CI is wrong or it's just that `docker` is not on `$PATH`, I don't know. Maybe ask the GitLab folks. I'm sure just running `docker info` instead of `mvnw` will fail. – Chanseok Oh Jan 14 '21 at 13:44
  • 1
    Same problem. Not sure but I think the docker binary shouldn't needed when building with JIP (thats the big advantage). From the docs: "Daemonless - Reduce your CLI dependencies. Build your Docker image from within Maven or Gradle and push to any registry of your choice. No more writing Dockerfiles and calling docker build/push." – Kevin Jan 21 '21 at 09:27
  • @Kevin you are right. As I said, I suggest you instruct Quarkus to directly push to your target registry instead of using Docker. Check the links in my first comment. – Chanseok Oh Jan 21 '21 at 14:12
  • fyi. Today they released a new version of quarkus and quarkus-container-image ist now stable. I haven't tested so far but I will in these days. – Kevin Jan 21 '21 at 14:14
  • Thx for answers, guys. I didn't tested the Chanseok solution, but I think it's valid to try for who has the same problem. As I said before, here we're using a job with Docker image to build and push our image. – G. Falcão Jan 29 '21 at 14:27
  • FYI, probably Quarkus is configured to push an image to a Docker daemon (hence Jib trying to use the `docker` CLI. Looks like you can prevent Quarkus from pushing to a Docker daemon. Check out [this thread](https://gitter.im/google/jib?at=6009e43b8816425540e014b4). – Chanseok Oh Feb 08 '21 at 15:30

0 Answers0