7

I have a custom gitlab ci that I want to compile a Golang app and build a docker image. I have decided to use alpine docker image for the gitlab runner. I can't seam to get docker started. I have tried to manually start docker and get an error ( * WARNING: docker is already starting ) and if I don't manually start the docker service I get (Fails (Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?) Any one else experience this?

This would not be a duplicate question. Gitlab runner runs the docker alpine container in root (verified by running whoami). For the sake of trying I did try usermod -aG docker $(whoami) and had the same output.

.gitlab-ci.yml

image: alpine

variables:
  GO_PROJECT: linkscout

before_script:
  - apk add --update go git libc-dev docker openrc
  - mkdir -p ~/go/src/${GO_PROJECT}
  - cp -r ${CI_PROJECT_DIR}/* ~/go/src/${GO_PROJECT}/
  - cd  ~/go/src/${GO_PROJECT}
  - service docker start #  * WARNING: docker is already starting

stages:
    - compile
    - build

compile:
    stage: compile
    script:
      - go get
      - go build -a

build:
    stage: build
    script:
     - docker version # If I don't run (service docker start) I get this message: Fails (Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?)
Trevor V
  • 1,958
  • 13
  • 33
  • Possible duplicate of [Docker command can't connect to Docker daemon](https://stackoverflow.com/questions/33562109/docker-command-cant-connect-to-docker-daemon) – MatTheWhale Jan 22 '18 at 23:06

1 Answers1

1

By default you cannot use Docker-in-docker. You should configure your runner like this. Then, as stated in the explanation also use docker:latest as image instead of alpine.

Stefan van Gastel
  • 4,330
  • 23
  • 25