I have the following problem - when I just use VPN with default settings in network manager - everything works as expected, and I see the following during build process:
#23 [backend base 8/12] RUN cat /etc/resolv.conf
#23 0.226 nameserver 10.x.x.x
#23 0.226 search some.internal.domain.com
#23 DONE 0.3s
$ nmcli dev show | grep -e DEVICE -e DNS
...
GENERAL.DEVICE: tun0
IP4.DNS[1]: 10.x.x.x
GENERAL.DEVICE: wlp2s0
IP4.DNS[1]: 192.168.1.1
...
But when I set up VPN via Network Manager to either Ignore automatically obtained routes
and setup some routes manually, or Use this connection only for resources on this network
+ specify DNS settings, everything works as expected on the host machine, but DNS address is not propagated to container during build:
#23 [backend base 8/12] RUN cat /etc/resolv.conf
#23 0.244 nameserver 192.168.1.1
#23 0.244 search some.internal.domain.com
#23 DONE 0.3s
$ nmcli dev show | grep -e DEVICE -e DNS
...
GENERAL.DEVICE: wlp2s0
IP4.DNS[1]: 192.168.1.1
GENERAL.DEVICE: tun0
IP4.DNS[1]: 10.x.x.x
...
If I perform this command with default VPN settings to make docker to cache results, and then edit VPN as specified above, everything works as expected at container run stage - internal resources are accessible over VPN. So the problem is only at the build stage.
How docker interacts with host to obtain DNS settings at build stage and how the problem could be solved?
Linux: Xubuntu 22.04.5 LTS
Network Manager: 1.36.6
Docker: version 28.0.4, build b8034c0
Image: python:3.12-slim-bookworm