Skip to content
This repository has been archived by the owner on Mar 21, 2022. It is now read-only.

gitlab ci dose not work with docker maven plugin #372

Closed
azizkhani opened this issue Feb 18, 2018 · 17 comments
Closed

gitlab ci dose not work with docker maven plugin #372

azizkhani opened this issue Feb 18, 2018 · 17 comments

Comments

@azizkhani
Copy link

I want build docker image in gitlab ci but i got this exception

Software:

  • docker-maven-plugin version: [1.3.4]
  • maven version: [3.3.9]

Full backtrace

[INFO] Building Docker context /builds/vahed98-monolithic/smart-gateway/target
[INFO] 
[INFO] Image will be built as vahed98-gateway:latest
[INFO] 
Feb 18, 2018 2:38:37 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.io.IOException) caught when processing request to {}->unix://localhost:80: No such file or directory
Feb 18, 2018 2:38:37 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {}->unix://localhost:80
Feb 18, 2018 2:38:37 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.io.IOException) caught when processing request to {}->unix://localhost:80: No such file or directory
Feb 18, 2018 2:38:37 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {}->unix://localhost:80
Feb 18, 2018 2:38:37 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.io.IOException) caught when processing request to {}->unix://localhost:80: No such file or directory
Feb 18, 2018 2:38:37 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {}->unix://localhost:80
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:11 min
[INFO] Finished at: 2018-02-18T14:38:37+00:00
[INFO] Final Memory: 54M/200M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:dockerfile-maven-plugin:1.3.4:build (default-cli) on project vahed98Front: Could not build image: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: java.io.IOException: No such file or directory -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
ERROR: Job failed: exit code 1
@azizkhani azizkhani changed the title gitlab ci dose not work with ddocker maven plugin gitlab ci dose not work with docker maven plugin Feb 18, 2018
@leandroBorgesFerreira
Copy link

Hello @azizkhami. Could you provide your gitlab configuration? I believe you are not using dind

@azizkhani
Copy link
Author

azizkhani commented Feb 19, 2018

I dont know why not work?

image: openjdk:8-jdk-alpine

services:
  - docker:dind


deploy:
  stage: test
  script:
    - './mvnw clean package -DskipTests=true dockerfile:build '
  only:
    - master

@leandroBorgesFerreira
Copy link

I believe you need to set the variables the docker host variable:
variables:
DOCKER_HOST: tcp://docker:2375/

@azizkhani
Copy link
Author

in .gitlab-ci.yml file?

@leandroBorgesFerreira
Copy link

Yes. Like this:

image: openjdk:8-jdk-alpine

services:
  - docker:dind
variables:
  DOCKER_HOST: tcp://docker:2375/
  DOCKER_DRIVER: overlay2

deploy:
  stage: test
  script:
    - './mvnw clean package -DskipTests=true dockerfile:build '
  only:
    - master

@leandroBorgesFerreira
Copy link

leandroBorgesFerreira commented Feb 19, 2018

@azizkhani Did this solution work for you?

@azizkhani
Copy link
Author

no

                   
Downloaded: https://repo.maven.apache.org/maven2/com/spotify/docker-client/8.8.1/docker-client-8.8.1-shaded.jar (7.4 MB at 3.3 MB/s)
[INFO] Using Google application default credentials
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 40.747 s
[INFO] Finished at: 2018-02-19T17:46:55Z
[INFO] Final Memory: 42M/101M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:dockerfile-maven-plugin:1.3.4:build (default-cli) on project vahed98Front: Execution default-cli of goal com.spotify:dockerfile-maven-plugin:1.3.4:build failed: Unparseable port number: docker:2375/ -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
ERROR: Job failed: exit code 1

@leandroBorgesFerreira
Copy link

Uhm... it looks like you have a different problem now. But I don't know what may be causing this =/. Maybe some maintainer of this library can help you

@azizkhani
Copy link
Author

yes it works fine 👍

@leandroBorgesFerreira
Copy link

@azizkhani Could your provide your solution to make your build work?

@azizkhani
Copy link
Author

azizkhani commented Feb 19, 2018

change to DOCKER_HOST: tcp://docker:2375

wnloaded: https://repo.maven.apache.org/maven2/com/spotify/docker-client/8.8.1/docker-client-8.8.1-shaded.jar (7.4 MB at 3.3 MB/s)
[INFO] Using Google application default credentials
[INFO] Building Docker context /builds/vahed98-monolithic/smart-gateway/target
[INFO] 
[INFO] Image will be built as vahed98-gateway:latest
[INFO] 
[INFO] Step 1/5 : FROM openjdk:8-jre-alpine
[INFO] 
[INFO] Pulling from library/openjdk
[INFO] Image ff3a5c916c92: Pulling fs layer
[INFO] Image 5de5f69f42d7: Pulling fs layer
[INFO] Image fa7536dd895a: Pulling fs layer
[INFO] Image 5de5f69f42d7: Downloading
[INFO] Image 5de5f69f42d7: Verifying Checksum
[INFO] Image 5de5f69f42d7: Download complete
[INFO] Image ff3a5c916c92: Downloading
[INFO] Image fa7536dd895a: Downloading
[INFO] Image ff3a5c916c92: Verifying Checksum
[INFO] Image ff3a5c916c92: Download complete
[INFO] Image ff3a5c916c92: Extracting
[INFO] Image ff3a5c916c92: Pull complete
[INFO] Image 5de5f69f42d7: Extracting
[INFO] Image 5de5f69f42d7: Pull complete
[INFO] Image fa7536dd895a: Verifying Checksum
[INFO] Image fa7536dd895a: Download complete
[INFO] Image fa7536dd895a: Extracting
[INFO] Image fa7536dd895a: Pull complete
[INFO] Digest: sha256:d3468b0fab294db03b4a67cabdaccf9c47a635ad14429ad43a0cce522e1ca8b3
[INFO] Status: Downloaded newer image for openjdk:8-jre-alpine
[INFO]  ---> b1bd879ca9b3
[INFO] Step 2/5 : ENV SPRING_OUTPUT_ANSI_ENABLED=ALWAYS     JHIPSTER_SLEEP=0     JAVA_OPTS=""
[INFO] 
[INFO]  ---> Running in 4b9ab9c155e2
[INFO] Removing intermediate container 4b9ab9c155e2
[INFO]  ---> 867c723ec09f
[INFO] Step 3/5 : ADD *.war /app.war
[INFO] 
[INFO]  ---> 52605187dab7
[INFO] Step 4/5 : EXPOSE 80
[INFO] 
[INFO]  ---> Running in bacbecb3084a
[INFO] Removing intermediate container bacbecb3084a
[INFO]  ---> 7fa426cbf314
[INFO] Step 5/5 : CMD echo "The application will start in ${JHIPSTER_SLEEP}s..." &&     sleep ${JHIPSTER_SLEEP} &&     java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar /app.war
[INFO] 
[INFO]  ---> Running in e4e555d27fbb
[INFO] Removing intermediate container e4e555d27fbb
[INFO]  ---> 3a150089a779
[INFO] Successfully built 3a150089a779
[INFO] Successfully tagged vahed98-gateway:latest
[INFO] 
[INFO] Detected build of image with id 3a150089a779
[INFO] Building jar: /builds/vahed98-monolithic/smart-gateway/target/app-docker-info.jar
[INFO] Successfully built vahed98-gateway:latest
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:05 min
[INFO] Finished at: 2018-02-19T17:51:27Z
[INFO] Final Memory: 44M/106M
[INFO] ------------------------------------------------------------------------
section_end:1519062688:build_script
�[0Ksection_start:1519062688:after_script
�[0Ksection_end:1519062690:after_script
�[0Ksection_start:1519062690:archive_cache
�[0Ksection_end:1519062691:archive_cache
�[0Ksection_start:1519062691:upload_artifacts
�[0Ksection_end:1519062693:upload_artifacts
�[0K�[32;1mJob succeeded
�[0;m

@leandroBorgesFerreira
Copy link

But did you do any change in the .gitlab-ci.yml file that I provided you? What's is your final version?

@azizkhani
Copy link
Author

yes remove / like this DOCKER_HOST: tcp://docker:2375

@leandroBorgesFerreira
Copy link

Oh, I see. Thanks =]

@naikaa
Copy link

naikaa commented Jan 17, 2019

or in the config.toml mount the volumes like this volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]

@mikhail-putilov
Copy link

mikhail-putilov commented Nov 26, 2019

If anybody encounters the same problem and finds this answer in google, instead of making blind guesses, better take a look at those two links, they are helpful and provide more value than the accepted answer:
(Second block of code) https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-disabled
https://docs.gitlab.com/runner/executors/kubernetes.html#using-dockerdind

@chaitanya003
Copy link

Could you share the link to your GITLAB project

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants