Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buildctl build RUN curl step failed, Could not resolve host #5412

Open
alazalazalaz opened this issue Oct 9, 2024 · 1 comment
Open

buildctl build RUN curl step failed, Could not resolve host #5412

alazalazalaz opened this issue Oct 9, 2024 · 1 comment

Comments

@alazalazalaz
Copy link

I did the following step to recurrent the error:

step1、vi docker-compose.yaml

version: '2.1'
services:
    buildkitd:
      image: moby/buildkit:v0.16.0
      container_name: buildkitd
      privileged: true
      restart: always
      command: ["--addr", "tcp://0.0.0.0:1234"]

step2、run the container
docker-compose -f docker-compose.yaml up -d buildkitd
step3、entry the container
docker exec -it 3a76a7e82807 /bin/sh
step4、test the container network

/ # nslookup www.google.com
Server:		127.0.0.11
Address:	127.0.0.11:53

Non-authoritative answer:
Name:	www.google.com
Address: 172.217.163.36

Non-authoritative answer:
Name:	www.google.com
Address: 2404:6800:4012:4::2004

the network is OK.

step5、create a Dockerfile, vi Dockerfile (still in the container)

FROM alpine/curl

RUN nslookup www.google.com

step6、build the Dockerfile (still in the container)
/ # buildctl --addr=tcp://0.0.0.0:1234 build --frontend=dockerfile.v0 --local context=. --local dockerfile=. --progress=plain
step7、 encounter the ERROR!

#4 [1/2] FROM docker.io/alpine/curl:latest@sha256:a9599b0ecdab1fb3c798985836248c51ba27577218e93c99bcc1ec61969acaf8
#4 extracting sha256:1010f67b3369ce6414bb7f1ebaea67db6912f2d4045960ee5f5386e56196de8a 0.0s done
#4 DONE 7.6s

#5 [2/2] RUN nslookup www.google.com
#5 10.31 nslookup: can't connect to remote host: Address not available
#5 ERROR: process "/bin/sh -c nslookup www.google.com" did not complete successfully: exit code: 1
------
 > [2/2] RUN nslookup www.google.com:
10.31 nslookup: can't connect to remote host: Address not available
------
Dockerfile:3
--------------------
   1 |     FROM alpine/curl
   2 |
   3 | >>> RUN nslookup www.google.com
   4 |
--------------------
error: failed to solve: process "/bin/sh -c nslookup www.google.com" did not complete successfully: exit code: 1

machine info:
Ubuntu 18.04.6
x86_64

cat /etc/resolv.conf on the Ubuntu machine:

nameserver 172.20.100.25
nameserver 172.20.100.27

the Ubuntu machine's network is perfectly fine.

cat /etc/resolv.conf in the container:

/ # cat /etc/resolv.conf
nameserver 127.0.0.11
options ndots:0

other steps:

  • when i change step5's Dockerfile, RUN nslookup www.google.com to curl -vvvv -s https://www.google.com,it produce a similar error :
> [2/4] RUN curl -vvvv -s https://www.google.com:
0.223 * Could not resolve host: www.google.com
0.223 * shutting down connection #0
  • when i run the step1-step6 on my own mac OS arm64, it works fine, no error.

so, why the build command failed?
Did i missed some config in the step 1?

@alazalazalaz
Copy link
Author

update.
I added network_mode:bridge in step1, partial RUN command works fun now, such as nslookup wget apt.
The curl command still failed, error :
curl: (6) Could not resolve host: www.google.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant