I am using docker+machine
to run my gitlab
ci/cd jobs.
So my .gitlab-ci.yml
looks like below:
stages:
- RUN_TESTS
image:
name: docker:stable
services:
- name: docker:dind
variables:
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
build-docker:
stage: RUN_TESTS
script:
- echo "Running the tests..."
- docker build -t run-tests .
This works totally fine with docker:dind
image set as the service
block as shown above.
Now here comes the fun part, I need some other packages inside the docker:dind
image. So I wrote the Dockerfile
as below:
FROM docker:dind
RUN apk update
ENV PYTHONUNBUFFERED=1
RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python
RUN python3 -m ensurepip
RUN pip3 install --no-cache --upgrade pip setuptools
RUN apk add groff
RUN pip3 install awscli
RUN apk --purge -v del py-pip
RUN rm /var/cache/apk/*
So, I built the above image and pushed it into my dockerhub.
As of now, everything is cool. Image built successfully and pushed successfully.
And then I changed the services
in the .gitlab-ci.yml
to my new images as below:
services:
- name: 199508/dind-new:latest
And I ran the pipeline and I get the error below.
This error I am getting below is strange:
error during connect: Post http://docker:2375/v1.40/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&labels=%7B%7D&memory=0&memswap=0&networkmode=default&rm=1&session=n6fvaaoisom3ny2cfozrlom50&shmsize=0&t=run-tests&target=&ulimits=null&version=1: dial tcp: lookup docker on : no such host
The only change I did was installing some applications/dependencies in the above Dockerfile
but why it is not working? How come when I use docker:dind
it is working and when I created a new Dockerfile
with the same docker:dind
base image and it doesn't work?
Can someone please help me?
question from:
https://stackoverflow.com/questions/65842641/docker-error-during-connect-post-http-docker2375-v1-40-build 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…