0
votes

I am using Jib to create a docker container and push it to the registry. To do that, I would like to build a Docker image that can be used for the purpose of container scanning before pushing the image to the Gitlab registry. The issue I am facing is I cannot use maven docker image for the build as it doesn't have docker agent running. I cannot use docker image as it doesn't have the maven image. Is there any way to address this without creating a custom docker image?

Here is my .gitlab-ci.yml file related to this part:

Building:
   image: docker:19.03.1 # or maven:3-jdk-8
   stage: build 
   only:
      - master
   script:
      - echo "Building the project"
      - mvn compile jib:dockerBuild

In case of docker image:

/bin/sh: eval: line 91: mvn: not found

In case of maven image:

Build to Docker daemon failed, perhaps you should make sure Docker is installed and you have correct privileges to run it
1
What is your runner configuration ? is running as docker in docker ?Tarun Khosla
@tarunkhosla I don't think so. It's the default Gitlab cloud runnerAli

1 Answers

-1
votes
  1. You can build jib using mvn compile jib:build and then make docker image and push to registry in next steps.

2 . Alternatively try running as docker in docker so that The gitlab runner can use Docker images to support our pipelines and use docker as image.

image: docker:latest
    services:
      - docker:dind
    Building:
       image: maven:3-jdk-8
       stage: build 
       only:
          - master
       script:
          - echo "Building the project"
          - mvn compile jib:dockerBuild