Skip to content

Dockerfile.rootfs: drop dangling /etc/resolv.conf symlink#205

Open
maxskokov wants to merge 1 commit into
openwrt:mainfrom
maxskokov:fix-rootfs-resolv-conf
Open

Dockerfile.rootfs: drop dangling /etc/resolv.conf symlink#205
maxskokov wants to merge 1 commit into
openwrt:mainfrom
maxskokov:fix-rootfs-resolv-conf

Conversation

@maxskokov

Copy link
Copy Markdown

What

/etc/resolv.conf in the rootfs image is a symlink to /tmp/resolv.conf. In
a build context /tmp is empty, so the symlink dangles and older buildkit
fails any RUN on the image with:

make mountpoint "/etc/resolv.conf": file exists

while trying to bind-mount the build-time resolv.conf over it, which makes
FROM openwrt/rootfs + any RUN unusable as a base image (#191). Docker
injects its own /etc/resolv.conf at runtime anyway, so the shipped symlink
is useless in the container image.

Removed in the builder stage before the rootfs is copied into the final
scratch image, so real firmware (where the symlink is intentional) is
untouched.

Verification

  • docker save of the rebuilt image: no layer contains etc/resolv.conf
    (before: lrwxrwxrwx etc/resolv.conf -> /tmp/resolv.conf).
  • Runtime DNS still works: nslookup downloads.openwrt.org resolves via
    Docker's mounted resolv.conf.
  • On buildkit >= v0.12 (tested v0.12.0 and v0.30) the original symptom no
    longer reproduces, so it was fixed upstream in buildkit at some point and
    the reporter hit it on an older version. The dangling symlink is still
    shipped though and breaks older buildkit for no benefit, so removing it is
    worthwhile and side-effect-free.

Fixes #191

The rootfs image ships /etc/resolv.conf as a symlink to /tmp/resolv.conf.
In a build context /tmp is empty, so the symlink dangles and older buildkit
fails any RUN step on the image with:

  make mountpoint "/etc/resolv.conf": file exists

when it tries to bind-mount the build-time resolv.conf over it. Docker
injects its own /etc/resolv.conf at runtime regardless, so the shipped
symlink serves no purpose in the container image. Remove it in the builder
stage before it is copied into the final scratch image.

Verified with `docker save` that no layer contains etc/resolv.conf after the
change, and that DNS still resolves at runtime via Docker's mounted
resolv.conf (nslookup downloads.openwrt.org succeeds).

Fixes: openwrt#191
Signed-off-by: Maxim Skokov <skokov.m020709@gmail.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

Successfully merging this pull request may close these issues.

The rootfs image can't be used as base image

1 participant