I'm trying to build a docker image with my application in Gitlab continuous integration using the jib Maven plugin, but I can't get the plugin connect to the docker daemon using the dind (docker-in-docker) service. Currently I'm using this configuration in my gitlab-ci.yml file:
deploy:mvn:
image: maven:3.6.3-jdk-8-openj9
stage: deploy
services:
- docker:dind
script:
- mvn compile jib:dockerBuild
This is the error I get:
[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:0.9.11:dockerBuild (default-cli) on project my-application: Build to Docker daemon failed, perhaps you should make sure Docker is installed and you have correct privileges to run it -> [Help 1]
UPDATE
I updated to 2.2.0 and it's running locally. I added the docker images
command before and the plugin seems not to be able to find the docker command in Gitlab CI:
$ docker images && mvn compile jib:dockerBuild /bin/bash: line 97: docker: command not found
This is the configuration for the jib plugin:
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>2.2.0</version>
<configuration>
<from>
<image>adoptopenjdk/openjdk11:alpine-jre</image>
</from>
<to>
<image>my-application:latest</image>
</to>
<container>
<entrypoint>
<shell>sh</shell>
<option>-c</option>
<arg>chmod +x /entrypoint.sh && sync && /entrypoint.sh</arg>
</entrypoint>
<ports>
<port>8080</port>
</ports>
<environment>
<SPRING_OUTPUT_ANSI_ENABLED>ALWAYS</SPRING_OUTPUT_ANSI_ENABLED>
<JHIPSTER_SLEEP>0</JHIPSTER_SLEEP>
</environment>
<creationTime>USE_CURRENT_TIMESTAMP</creationTime>
</container>
</configuration>
</plugin>
script: - docker images && mvn compile jib:dockerBuild
to see if thedocker
command is on PATH. – Chanseok Ohdocker
command is not available in the image. See my answer below. – Chanseok Oh