简体   繁体   English

容器内的docker pull图像因超时而失败

[英]docker pull image inside a container fails with a timeout

I am running a docker-compose that has 3 services.我正在运行一个有 3 个服务的 docker-compose。 My main service depends on an image service which depends on a dind-service我的主要服务依赖于依赖于dind-service的图像服务

  service-1:
    image: 'someimage'
    privileged: true
    ports:
      - '8911:8911'
    environment:
      - docker-compose=true
    volumes:
      - scratch:/tmp/scratch
      - bundles:/tmp/bundles:ro
    command: http-compile
    depends_on:
      - img

  img-service:
    image: 'img'
    privileged: true
    ports:
      - '8909:8909'
    environment:
      - DOCKER_HOST=tcp://dind-img:2375
    volumes:
      - bundles:/tmp/bundles
      - ./deploy/path/to/config.json:/etc/config.json
    command: runc-setup
    depends_on:
      - dind-img

  dind-service:
    image: docker:18-dind
    privileged: true
    volumes:
      - execimages:/var/lib/docker
      - tmp:/tmp

All these services images are built locally but one of the services fetches other images (like language runtimes, for example Go) from the net and builds them locally inside the container.所有这些服务镜像都是在本地构建的,但其中一个服务从网络获取其他镜像(如语言运行时,例如 Go)并在容器内本地构建它们。

But while fetching the image I get timeout errors and because of that my service which depends on the other two services fails.但是在获取图像时出现超时错误,因此我依赖于其他两个服务的服务失败。

I was doing this from my workplace and I tried to see if we had a proxy configured but running the command env | grep proxy我是在我的工作场所这样做的,我试图查看我们是否配置了代理但运行了命令env | grep proxy env | grep proxy gave me nothing. env | grep proxy什么也没给我。

So it is likely not a network problem, maybe something to do with my docker-setup.所以这可能不是网络问题,可能与我的 docker-setup 有关。

folks at my workplace who develop this project on Mac have never faced this issue with docker pull.在我的工作场所,在 Mac 上开发这个项目的人从未遇到过 docker pull 的这个问题。 I am on Ubuntu 18.04我在 Ubuntu 18.04

I ran a shell script from the docker repol to check the config to check whats missing and these were all the missing results.我从 docker repol 运行了一个shell 脚本来检查配置以检查丢失的内容,这些都是丢失的结果。 Are any of these causing the problem?这些是否会导致问题?

CONFIG_NF_NAT_IPV4: missing
CONFIG_NF_NAT_NEEDED: missing
CONFIG_MEMCG_SWAP_ENABLED: missing
CONFIG_IOSCHED_CFQ: missing
CONFIG_CFQ_GROUP_IOSCHED: missing
CONFIG_RT_GROUP_SCHED: missing
CONFIG_INET_XFRM_MODE_TRANSPORT: missing
zfs command: missing
zpool command: missing

Check your logs to see if you see anything like this:检查您的日志,看看您是否看到类似以下内容:

[0683] Handler for POST /images/create returned error: Get https://registry-1.docker.io....: dial tcp: lookup registry-1.docker.io on 8.8.8.8:53: read udp 192.168.0.163:32769->8.8.8.8:53: read: connection refused (or timeout)

This suggests that the DNS query is being run from an ephemeral port on your ubuntu and DNS servers either timeout or reject the request.这表明 DNS 查询正在从您的 ubuntu 和 DNS 服务器上的临时端口运行,超时或拒绝请求。

Instead add your local DNS cache/server as the primary on resolve.conf eg cat /etc/resolv.conf而是将您的本地 DNS 缓存/服务器添加为 resolve.conf 的主要服务器,例如 cat /etc/resolv.conf

nameserver 192.168.0.1
nameserver 8.8.8.8
....

Then your docker pull should work successfully.然后您的 docker pull 应该可以成功运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM