Closed azizkhani closed 6 years ago
Hello @azizkhami. Could you provide your gitlab configuration? I believe you are not using dind
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
I believe you need to set the variables the docker host variable: variables: DOCKER_HOST: tcp://docker:2375/
in .gitlab-ci.yml file?
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
@azizkhani Did this solution work for you?
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
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
yes it works fine 👍
@azizkhani Could your provide your solution to make your build work?
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
But did you do any change in the .gitlab-ci.yml file that I provided you? What's is your final version?
yes remove / like this DOCKER_HOST: tcp://docker:2375
Oh, I see. Thanks =]
or in the config.toml mount the volumes like this volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
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
Could you share the link to your GITLAB project
I want build docker image in gitlab ci but i got this exception
Software:
Full backtrace