-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Hi,
I have a host system with systemd-resolved configured. With moby/moby#41022 a more thorough decision concept - on whether /etc/resolv.conf or /run/systemd/resolve/resolv.conf should be selected - was implemented. In short, when I activate the host networking mode during build, I would expect to have /etc/resolv.conf copied from my host into the container. The selection works fine for me for all docker commands, like run and build. I've noticed that when I activate buildkit, however, the behavior is different. It seems like /run/systemd/resolve/resolv.conf is used always, regardless of whether the host network option is selected via --network host.
Example
Dockerfile
FROM debian:stable-slim as test
RUN cat /etc/resolv.confWithout Buildkit
docker build --no-cache .
Sending build context to Docker daemon 2.048kB
Step 1/2 : FROM debian:stable-slim as test
---> a59bf83b71db
Step 2/2 : RUN cat /etc/resolv.conf
---> Running in e28a441f215f
# This is /run/systemd/resolve/resolv.conf managed by man:systemd-resolved(8).
# Do not edit.
#
# This file might be symlinked as /etc/resolv.conf. If you're looking at
# /etc/resolv.conf and seeing this text, you have followed the symlink.
#
# This is a dynamic resolv.conf file for connecting local clients directly to
# all known uplink DNS servers. This file lists all configured search domains.
#
# Third party programs should typically not access this file directly, but only
# through the symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a
# different way, replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.
nameserver 192.168.0.1
search fritz.box mycompany.com
Removing intermediate container e28a441f215f
---> d8068b2e8e0a
docker build --no-cache --network host .
Sending build context to Docker daemon 2.048kB
Step 1/2 : FROM debian:stable-slim as test
---> a59bf83b71db
Step 2/2 : RUN cat /etc/resolv.conf
---> Running in bf6e9a9a717b
# This is /run/systemd/resolve/stub-resolv.conf managed by man:systemd-resolved(8).
# Do not edit.
#
# This file might be symlinked as /etc/resolv.conf. If you're looking at
# /etc/resolv.conf and seeing this text, you have followed the symlink.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs should typically not access this file directly, but only
# through the symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a
# different way, replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.
nameserver 127.0.0.53
options edns0 trust-ad
search fritz.box mycompany.com
Removing intermediate container bf6e9a9a717b
---> 8918cfff6943
With Buildkit
DOCKER_BUILDKIT=1 docker build --no-cache --progress plain .
I expect to have /run/systemd/resolve/resolv.conf copied, as I use the default networking mode (as above).
#5 [2/2] RUN cat /etc/resolv.conf
#5 sha256:545184e0f05d6f855b6b5907cc3e8725388186066a75e48d6a936aa232d3bfd8
#5 0.347 # This is /run/systemd/resolve/resolv.conf managed by man:systemd-resolved(8).
#5 0.347 # Do not edit.
#5 0.347 #
#5 0.347 # This file might be symlinked as /etc/resolv.conf. If you're looking at
#5 0.347 # /etc/resolv.conf and seeing this text, you have followed the symlink.
#5 0.347 #
#5 0.347 # This is a dynamic resolv.conf file for connecting local clients directly to
#5 0.347 # all known uplink DNS servers. This file lists all configured search domains.
#5 0.347 #
#5 0.347 # Third party programs should typically not access this file directly, but only
#5 0.347 # through the symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a
#5 0.347 # different way, replace this symlink by a static file or a different symlink.
#5 0.347 #
#5 0.347 # See man:systemd-resolved.service(8) for details about the supported modes of
#5 0.347 # operation for /etc/resolv.conf.
#5 0.347
#5 0.347 nameserver 192.168.0.1
#5 0.347 nameserver fd00::3ea6:2fff:febc:9583
#5 0.347 search fritz.box mycompany.com
#5 DONE 0.4s
#6 exporting to image
#6 sha256:e8c613e07b0b7ff33893b694f7759a10d42e180f2b4dc349fb57dc6b71dcab00
#6 exporting layers 0.0s done
DOCKER_BUILDKIT=1 docker build --no-cache --progress plain --network host .
I expect to have /etc/resolv.conf from my host copied, as I use the default networking mode host.
But instead, the same file as above was copied to the image.
#5 [2/2] RUN cat /etc/resolv.conf
#5 sha256:5c4fe41150f29d92ec2ef20be016044fcab54f17a063d0efcbade71252e99f3a
#5 0.254 # This is /run/systemd/resolve/resolv.conf managed by man:systemd-resolved(8).
#5 0.254 # Do not edit.
#5 0.254 #
#5 0.254 # This file might be symlinked as /etc/resolv.conf. If you're looking at
#5 0.254 # /etc/resolv.conf and seeing this text, you have followed the symlink.
#5 0.254 #
#5 0.254 # This is a dynamic resolv.conf file for connecting local clients directly to
#5 0.254 # all known uplink DNS servers. This file lists all configured search domains.
#5 0.254 #
#5 0.254 # Third party programs should typically not access this file directly, but only
#5 0.254 # through the symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a
#5 0.254 # different way, replace this symlink by a static file or a different symlink.
#5 0.254 #
#5 0.254 # See man:systemd-resolved.service(8) for details about the supported modes of
#5 0.254 # operation for /etc/resolv.conf.
#5 0.254
#5 0.254 nameserver 192.168.0.1
#5 0.254 nameserver fd00::3ea6:2fff:febc:9583
#5 0.254 search fritz.box mycompany.com
#5 DONE 0.3s
#6 exporting to image
#6 sha256:e8c613e07b0b7ff33893b694f7759a10d42e180f2b4dc349fb57dc6b71dcab00
#6 exporting layers 0.0s done
I would expect the behavior to be same after enabling buildkit.