moby: Cannot install resolvconf on Ubuntu 12.04 containers

Docker currently bind-mounts to the container’s /etc/resolv.conf. This causes problems when installing utilities such as resolvconf/dnsmasq/dhcpd, because /etc/resolv.conf needs to overwritable. Here’s the output when trying to run resolvconf:

lsattr: Inappropriate ioctl for device While reading flags on /etc/resolv.conf
ln: cannot remove `/etc/resolv.conf: Device or resource busy

However, /etc/resolv.conf is a sensible default location. Can we instead make the mount location configurable?

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Reactions: 1
  • Comments: 48 (30 by maintainers)

Commits related to this issue

Most upvoted comments

@zuazo I’ve ended up doing something similar:

RUN echo "resolvconf resolvconf/linkify-resolvconf boolean false" | debconf-set-selections

Hey folks, if you’re like me and ended up here because you’re trying to dockerize some old busted software that insists on installing resolvconf on Ubuntu 12.04, you can workaround it by configuring resolvconf to skip the post install step where it link-ifies /etc/resolv/conf:

RUN apt-get -y install debconf-utils && echo resolvconf resolvconf/linkify-resolvconf boolean false | debconf-set-selections && apt-get -y install resolvconf

Just a quick update, the implemented fixes do not fix that issue that is the resolvconf package for Debian, see the following apt output on debian jessie:

Setting up resolvconf (1.76.1) ...
ln: cannot remove '/etc/resolv.conf': Device or resource busy
dpkg: error processing package resolvconf (--configure):
 subprocess installed post-installation script returned error exit status 1

Which in turn prevents packages that depends on resolvconf from installing. I could probably create a bunch of fake packages that provide those kind of broken packages, but I’d rather have a nicer way to make it work directly in docker.

@gurjeet you may inspire yourself from our ubuntu image (running fine with latest lxc git tree & docker one): https://github.com/makinacorpus/vms/tree/master/docker/makinacorpus/ubuntu_template (see the make.sh 2 level backward to look on how we construct the image (2 times install) )

It would be nice though to have a “just don’t touch the stinking resolv.conf file” option in the cases where you do need to mess with it during a build or you in fact do want 127.0.1.1 to be your name server or the other cases where docker ‘helps’. We used #1383 partly for this purpose – we killed the bind-mount, ADDed an installer script in the Dockerfile and RUN’d the script. So the resolv.conf file is written in the installer script and sticks for the length of it’s execution – actually we write resolv.conf twice in our installer script, but you get the idea. The resolv.conf file is then empty on subsequent RUN commands, but it works. Either way, a “stop ‘helping’ /etc/resolv.conf” option would be great.

Another, wrong way-but-works-way to partly work around this is to remove /var/lib/docker/graph/_tmp/docker/etc/resolv.conf which will keep it out of the way. Since it’s empty, you can recreate it easily enough later.

As an aside, having some switch to add a “search” line to /etc/resolv.conf would be super handy.