Can’t access docker in the test stage fo my multistage CI pipe
The pipe begins with a docker build and push in the build stage, this is successful and the image is pushed to the container registry. This is followed by the test stage which fails on the first script with a docker run command as the pipeline looks to longer have access to the docker host.
docker: error during connect: Post http://docker:2376/v1.40/containers/create?name=apisprout: dial tcp: lookup docker on 127.0.0.11:53: no such host.
This is using the running on gitlab.com and with the below .gitlab-ci.yml
stages:
- build
- test
services:
- docker:dind
variables:
# Enable network-per-build to allow gitlab services to see one another
FF_NETWORK_PER_BUILD: "true"
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_CERTDIR: '/certs'
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
# IMAGE SETTINGS
NODE_ENV: "development"
API_URL: "http://localhost:8000"
PORT: 8080
build:
stage: build
image: docker
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t ${CI_REGISTRY_IMAGE}:test .
- docker push ${CI_REGISTRY_IMAGE}:test
test:
stage: test
image: docker
services:
- name: ${CI_REGISTRY_IMAGE}:test
alias: server
script:
- docker run --rm --name apisprout -d -p 8000:8000 -v $CI_PROJECT_DIR/v2-spec.yml:/api.yaml danielgtaylor/apisprout /api.yaml
- docker run --rm --name newman -d -v $CI_PROJECT_DIR:/etc/newman postman/newman run 'Micros V2.postman_collection.json'
I’ve tried to edit the docker host settings, but have only succeeded in causing the build stage of the pipe to fail.