连接期间的Docker错误:发布http://docker:2375/v1.40/build? [英] Docker error during connect: Post http://docker:2375/v1.40/build?

查看:1006
本文介绍了连接期间的Docker错误:发布http://docker:2375/v1.40/build?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 docker + machine 运行我的 gitlab ci/cd作业.

I am using docker+machine to run my gitlab ci/cd jobs.

所以我的 .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 .

对于上面设置为 service 块的 docker:dind 映像,这完全可以正常工作.

This works totally fine with docker:dind image set as the service block as shown above.

现在这是有趣的部分,我需要在 docker:dind 图像内添加一些其他软件包.所以我写了 Dockerfile 如下:

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/*

因此,我构建了上面的图像并将其推送到我的dockerhub中.

So, I built the above image and pushed it into my dockerhub.

截至目前,一切都很棒.图像成功构建并成功推送.

As of now, everything is cool. Image built successfully and pushed successfully.

然后我将 .gitlab-ci.yml 中的 services 更改为新图像,如下所示:

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:

连接期间发生

错误:发布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 = tamp; target =& ulimits = null& version = 1:拨打tcp:在以下位置查找docker主机:没有此类主机

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

我所做的唯一更改是在上面的 Dockerfile 中安装了一些应用程序/依赖项,但是为什么它不起作用?当我使用 docker:dind 起作用时,以及使用相同的 docker:dind 基本映像创建新的 Dockerfile 时,为什么会这样呢?不行吗?

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?

有人可以帮我吗?

推荐答案

实际上我昨天才遇到这个问题最主要的是切换到Docker映像版本就您而言,Dockerfile中的情况不像这里

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

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

这篇关于连接期间的Docker错误:发布http://docker:2375/v1.40/build?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆