[英]Docker error during connect: Post http://docker:2375/v1.40/build?
I am using docker+machine
to run my gitlab
ci/cd jobs.我正在使用 docker
docker+machine
运行我的gitlab
ci/cd 作业。
So my .gitlab-ci.yml
looks like below:所以我的
.gitlab-ci.yml
如下所示:
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.这完全适用于
docker:dind
图像集作为service
块,如上所示。
Now here comes the fun part, I need some other packages inside the docker:dind
image.现在有趣的部分来了,我需要
docker:dind
图像中的一些其他包。 So I wrote the Dockerfile
as below:所以我写了
Dockerfile
如下:
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.因此,我构建了上面的图像并将其推送到我的 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:然后我将
.gitlab-ci.yml
中的services
更改为我的新图像,如下所示:
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
连接期间出现错误:发布 http://docker:2375/v1.40/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&s=%7B%7D 0&memswap=0&networkmode=default&rm=1&session=n6fvaaoisom3ny2cfozrlom50&shmsize=0&t=run-tests&target=&ulimits=null&version=1:拨tcp:查找Z05B6053C41A2130AFD6FC3B15B上没有这样的主机:
The only change I did was installing some applications/dependencies in the above Dockerfile
but why it is not working?我所做的唯一更改是在上述
Dockerfile
中安装一些应用程序/依赖项,但为什么它不起作用? 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?当我使用
docker:dind
它正在工作时,当我使用相同的docker:dind
基本图像创建一个新的Dockerfile
并且它不起作用时,怎么会这样?
Can someone please help me?有人可以帮帮我吗?
Actually I just run into this problem yesterday The main thing is to switch to docker image version In Your case in the Dockerfile not like here其实我昨天刚遇到这个问题主要是切换到docker镜像版本在你的情况下Dockerfile不像这里
FROM docker:18.09
And change the port: The lines commented out are the once the didn't work for me.并更改端口:注释掉的行是曾经对我不起作用的行。
image: 199508/dind-new:v5
services:
# - docker:19.03.12-dind
- docker:18.09-dind
variables:
# Use TLS https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled
DOCKER_HOST: tcp://docker:2375/
# DOCKER_HOST: tcp://docker:2376
# DOCKER_TLS_CERTDIR: "/certs"
DOCKER_TLS_CERTDIR: ""
CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:latest
DOCKER_DRIVER: overlay2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.