I’m trying to create a test phase for a repo. It’s built with Go. The issue is that the go tests need to invoke docker to run, so that means that for the tests to run I need to invoke docker in docker.
I have no clue on how to do this. I have tried many things, but nothing is working, so far my gitlab-ci.yml file looks like this:
variables:
PATH: $PATH:/usr/local/go/bin
#image: docker:latest
image: ubuntu:bionic
cache:
paths:
- /apt-cache
- /go/src/github.com
- /go/src/golang.org
- /go/src/google.golang.org
- /go/src/gopkg.in
stages:
- test
- build
before_script:
- apt-get update && apt-get install -y wget
- rm -rf /usr/local/go
- wget -O go.tgz https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz
- tar -C /usr/local -xzf go.tgz
- rm go.tgz
- which go
- go version
unit_tests:
stage: test
services:
- docker:dind
- postgres:11.1-alpine
script:
- make test
However that results in the following error:
ERROR: Preparation failed: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"dockerd-entrypoint.sh\": executable file not found in $PATH": unknown (docker.go:506:0s)
Will be retried in 3s ...
Using Docker executor with image ubuntu:bionic ...
Starting service docker:dind ...
Pulling docker image docker:dind ...
Using docker image sha256:7799c84f00cd5b6d6c537ef3e0211866e35f09cfcfca6f979c9df1098e55b365 for docker:dind ...
ERROR: Preparation failed: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"dockerd-entrypoint.sh\": executable file not found in $PATH": unknown (docker.go:506:0s)
Will be retried in 3s ...
ERROR: Job failed (system failure): Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"dockerd-entrypoint.sh\": executable file not found in $PATH": unknown (docker.go:506:0s)
How can I get this to work?