ubuntu Docker构建:proxyconnect tcp:在X.X.X.X上拨打tcp:lookup http:53:无此类主机

iezvtpos  于 2023-05-06  发布在  Docker
关注(0)|答案(1)|浏览(482)

当我尝试构建Docker镜像时:

DOCKER_BUILDKIT=1 docker build -f "tools/docker/Dockerfile" -t hello:latest --target hello "."

我从FROM ubuntu:impish AS baseimg得到这个错误:

ERROR: failed to solve: failed to fetch oauth token: Post "https://auth.docker.io/token": proxyconnect tcp: dial tcp: lookup http on 127.0.0.1:53: no such host

我尝试在/etc/resolv.conf中设置nameserver并重启docker。它显示相同的错误与127.0.0.1更改为DNS IP我刚刚设置.实际上,nslookup auth.docker.io可以很好地与任何DNS服务器配合使用。docker pull也很好用。这个问题只在我试图构建图像时出现。
我也试过docker logout; docker login,关闭或打开代理。他们都不能解决问题。
一些信息:

  • 系统:Ubuntu 22.04
  • docker版本:Docker版本23.0.5,构建版本bc4487a
  • docker info
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.10.4
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.17.3
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 1
  Running: 0
  Paused: 0
  Stopped: 1
 Images: 3
 Server Version: 23.0.5
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 2806fc1057397dbaeefbea0e4e17bddfbd388f38
 runc version: v1.1.5-0-gf19387a
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.19.0-41-generic
 Operating System: Ubuntu 22.04.2 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 12
 Total Memory: 31.15GiB
 Name: Ubuntu-Inspiron-5680
 ID: 56fe649e-4761-4b6d-a258-828187c1f242
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: fals

谁能给予我一些建议?

luaexgnf

luaexgnf1#

只需在Dockerfile中添加(在尝试从互联网上拉取任何内容之前):

COPY /etc/resolv.conf /etc/resolv.conf

或者,如果你不想依赖于主机的/etc/resolv.conf,你可以在building image中硬编码nameserver

RUN echo "nameserver 1.1.1.1" >> /etc/resolv.conf

相关问题