Open tgquan67 opened 1 year ago
I can second this and can recreate it.
Dockerfile:
FROM ubuntu:22.10
RUN cat /etc/hosts
Build with DOCKER_BUILDKIT=0
(/etc/hosts
is propagated as expected):
$ DOCKER_BUILDKIT=0 docker build --network=host .
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
BuildKit is currently disabled; enable it by removing the DOCKER_BUILDKIT=0
environment-variable.
Sending build context to Docker daemon 15.06MB
Step 1/2 : FROM ubuntu:22.10
---> 91e34ae906cf
Step 2/2 : RUN cat /etc/hosts
---> Running in 706f6313eb3b
127.0.0.1 localhost
123.123.123.123 customhost
[...]
contents from /etc/hosts on local machine
[...]
Removing intermediate container 706f6313eb3b
---> 95c682678349
Successfully built 95c682678349
Build with DOCKER_BUILDKIT=1
(/etc/hosts
is not propagated):
$ docker build --network=host --progress=plain .
#1 [internal] load .dockerignore
#1 transferring context: 2B done
#1 DONE 0.0s
#2 [internal] load build definition from Dockerfile
#2 transferring dockerfile: 95B done
#2 DONE 0.0s
#3 [internal] load metadata for docker.io/library/ubuntu:22.10
#3 DONE 0.0s
#4 [1/2] FROM docker.io/library/ubuntu:22.10
#4 CACHED
#5 [2/2] RUN cat /etc/hosts
#0 0.098 127.0.0.1 localhost buildkitsandbox
#0 0.098 ::1 localhost ip6-localhost ip6-loopback
#5 DONE 0.1s
#6 exporting to image
#6 exporting layers 0.0s done
#6 writing image sha256:b4f9a7fd4d366808fb6660a62b63d00290cb21bee684d2d8733c7b98b9a1daee done
#6 DONE 0.0s
Is this an expected result? Am I doing something wrong? Or is this a bug?
At this moment, I'm afraid that our sole option is to utilize an external DNS resolver that we manage and point the buildx builders towards it. Following a sample /etc/docker/daemon.json DNS config.
{
"dns": [
"172.x.x.x"
]
}
Hi, guys
Does any workaround?
In my case, --network=host
does not affect /etc/hosts
, and --add-host host:ip
works fine.
But I have entries large than 20, I don't want to write 20 --add-host
for docker buildx build
Contributing guidelines
I've found a bug and checked that ...
Description
Even when I enabled
network=host
, buildx is not picking up entries in host's/etc/hosts
. First I created a new builder withwith the content of
~/.config/buildkit/buildkitd.toml
asI also added
127.0.0.1 random.blah
to host's/etc/hosts
and tried to build the following dockerfilewith the following command
Expected behaviour
When I have
DOCKER_BUILDKIT=0
, the result is as followActual behaviour
When buildkit is used, I get this result
Buildx version
github.com/docker/buildx v0.10.2 00ed17d
Docker info
Builders list
Configuration
Logs
Additional info
No response