I have a GitLab pipeline that I want to:
- Build a Java app
- Test using docker-compose
- Push to my Docker repository
The primary issue I'm having is that this works:
services:
  - docker:dind
docker_test:
  stage: docker_test
  image: docker:latest
  script:
  - docker version
The output is printed as expected:
> gitlab-ci-multi-runner exec docker --docker-privileged docker_test
...
$ docker version
Client:
 Version:      17.06.0-ce
...
Server:
 Version:      17.06.0-ce
...
Build succeeded
While this does not (installation steps for docker-ce omitted):
services:
  - docker:dind
docker_test:
  stage: docker_test
  image: ubuntu:latest       << note change
  script:
  - docker version
It fails with:
$ docker version
Client:
 Version:      17.06.0-ce
 API version:  1.30
 Go version:   go1.8.3
 Git commit:   02c1d87
 Built:        Fri Jun 23 21:23:31 2017
 OS/Arch:      linux/amd64
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
ERROR: Build failed: exit code 1
FATAL: exit code 1
How do I make my ubuntu image (or whatever image is going to build my project) connect to the linked Docker-in-Docker service? What is docker:latest doing that I'm not?
I've read up on the GitLab services documentation, but it only makes sense to me from a hostname perspective. (If you have a mysql service, you can connect over mysql:3306.)
Edit: Updating the command to echo $DOCKER_HOST, I see in the docker:latest image:
$ echo $DOCKER_HOST
tcp://docker:2375
And in the ubuntu:latest image I see:
$ echo $DOCKER_HOST
(nothing - but SO doesn't let me add a blank code line)
 
     
    