I'm new to Docker, but have a Java web app project for which my Maven build produces and installs a Docker image. i.e.
mvn clean install
Produces:
REPOSITORY TAG IMAGE ID CREATED SIZE
registry.gitlab.com/me/myapp 0.0.1-SNAPSHOT-dev 12d69e5ab28b 45 minutes ago 666 MB
I'm making use of Spotify's Maven plugin to build this, which I can then deploy to the repository using:
mvn docker:push
Which works great. However: I'm using GitLab for CI, and my .gitlab-ci.yml file contains:
image: maven:3.3.9-jdk-8
build:
script: "mvn clean install && mvn docker:push"
This nearly works, but fails as Docker is not installed in my container which is running the build:
[INFO] Building image registry.gitlab.com/me/myapp
Dec 31, 2016 8:30:45 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
Dec 31, 2016 8:30:45 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {}->unix://localhost:80
Dec 31, 2016 8:30:45 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
... (more of the same) ...
It seems the solution here is to install Docker into the container. I can't find a pre-built image that has Java, Maven and Docker, but I did try configuring Docker as a service:
services:
- docker:1.13-rc
But the result is the same - it seems services are meant to be used as external services that can be connected to, but that are not immediately installed within the same container.
How should I go about updating my .yml file so that the GitLab build can build and push a Docker image?