Replies: 1 comment
-
|
@eljonny this is a known buildkit bug with systemd-resolved: moby/buildkit#5009. when buildx uses the the reason earlier stages work is almost certainly layer caching from a previous successful build. run fix -- check which driver you're using and switch: # check current builder
docker buildx ls
# if using docker-container, switch to the default docker driver
docker buildx use default
# rebuild
docker compose build --no-cacheif you need docker-container (e.g., multi-platform builds), mount the host's DNS config: docker buildx create \
--name fixed-builder \
--driver docker-container \
--driver-opt "network=host" \
--bootstrap
docker buildx use fixed-builderthen build with host networking so DNS resolves correctly: # docker-compose.yml
services:
main-app:
build:
context: .
network: hostnuclear option if nothing else works -- bypass systemd-resolved entirely: sudo rm /etc/resolv.conf
echo -e "nameserver 1.1.1.1\nnameserver 9.9.9.9" | sudo tee /etc/resolv.confthis forces real DNS servers instead of the 127.0.0.53 stub resolver that confuses buildkit. you can revert by running |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am working on a custom deployment of some open source software where some of the code needs to be modified to provide a couple additional features that are not present, so I'm working on making modifications and rebuilding the
main-appimage.I would ask this on the main repo (paperless-ngx) but I feel like this is more of a docker build issue than something specific to that project.
This is a project I'm working on in my spare time and I have been searching for a solution for this for the last 3 weeks.
The core problem is this:
When I run the docker multi-stage build, every stage but the final stage (called main-app) does not have DNS issues, but the final stage is not able to resolve deb.debian.org.
I cannot get Docker to build the main-app image on Linux (Xubuntu 24.04) but it works OK in Docker Desktop on Windows, which is bizarre and usually the case is the opposite, works right on Linux and not on Windows.
Docker versions:
Docker version 28.2.2, build 28.2.2-0ubuntu1~24.04.1Docker Compose version 2.37.1+ds1-0ubuntu2~24.04.1github.com/docker/buildx 0.21.3 0.21.3-0ubuntu1~24.04.1Here is the Dockerfile (unmodified from the 2.17.1 source):
I have tried the following things:
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0docker buildx create --platform 'linux/amd64' --use --name 'pngx-builder' --driver 'docker-container' --driver-opt 'network=bridge' --buildkitd-flags '--oci-worker-net bridge' --bootstrapdocker buildx create --platform 'linux/amd64' --use --name 'pngx-builder-hn' --driver 'docker-container' --driver-opt 'network=host' --buildkitd-flags '--allow-insecure-entitlement network.host --oci-worker-net host' --bootstrap--no-cacheand cached modedocker compose builddocker compose --all-resources --progress=plain build --no-cache --builder 'pngx-builder' --with-dependenciesdocker compose --all-resources --progress=plain build --no-cache --builder 'pngx-builder-hn' --with-dependenciesdocker composedocker buildx prune --all --forcerepeatedlycat /etc/resolv.confin the Dockerfile RUN command in the main-app image and verified the name servers are present as they should be.sudo ufw statusThis is my current daemon config (at /etc/docker/daemon.json):
{ "dns": [ "1.1.1.1", "1.0.0.1", "9.9.9.9", "208.67.222.222", "208.67.220.220" ] }This is the current configuration for systemd-resolved that disables the stub resolver (at /etc/systemd/resolved.conf.d/docker.conf):
This is the current configuration for ensuring known-good DNS name servers are available through systemd-resolved (at /etc/systemd/resolved.conf.d/userdns.conf):
Something is blocking DNS resolution in the final image stage in the multi-stage build (main-app), and I cannot for the life of me figure out what it is.
This is what happens for the big RUN command in main-app:
I have seen many mentions of issues like this on the Docker forums and in limited instances elsewhere, but nowhere have I found a concrete resolution for it.
I feel like I have tried everything, I hope someone here might be able to help. Here is the full build log.
Also posted/asked on SO.
Beta Was this translation helpful? Give feedback.
All reactions