You are not logged in.

#1 2018-01-20 04:18:35

theonlylawislove
Member
Registered: 2015-01-05
Posts: 38

"error: Partition /etc/resolv.conf is mounted read only" in container.

I have a docker image that is an Arch image. In order for network to work, I have to bind the /etc/resolv.conf in the image. If I mount the /etc/resolve.conf as rw, it works. If I mount ro (preferred), it doesn't.

checking keyring...
checking package integrity...
loading package files...
checking for file conflicts...
checking available disk space...
error: Partition /etc/resolv.conf is mounted read only
error: not enough free disk space
error: failed to commit transaction (not enough free disk space)
Errors occurred, no packages were upgraded.

When checking available disk space, it should skip file mounts, correct? There is plenty of disk space left in the root.

Offline

#2 2018-01-20 04:22:10

theonlylawislove
Member
Registered: 2015-01-05
Posts: 38

Re: "error: Partition /etc/resolv.conf is mounted read only" in container.

In the short term, I am copying host /etc/hosts and /etc/resolv.conf to temporary directories on host, and then mounting them as rw. That way, I have never fear of messing with the host system.

Offline

#3 2018-01-20 09:35:53

EmilyShepherd
Member
From: Bucks, UK
Registered: 2016-03-20
Posts: 45
Website

Re: "error: Partition /etc/resolv.conf is mounted read only" in container.

Hi theonlylawislove,

In principle, your "short term" solution is really the best way to do this going forward. The reason for this is that, when you bind mount a file into a docker container, it is the same file on both the host and the container - any changes on the host will reflect into the container and, more seriously, any changes on the container will reflect onto the host. So if you do want to mount arbitrary files onto a container and you want these to be container writable but not reflect up to the host, you will always have to copy this file first.

By the way, did you know that docker already has a special case for the /etc/resolve.conf file? If you don't specify it at all, it will automatically create a copy, strip out any nameservers pointing to localhost (as these are accessible from the container anyway) and bind mount it for you.

For example:

Show what the host resolv.conf looks like:

$ cat /etc/resolv.conf
nameserver 8.8.8.8
nameserver 127.0.0.1

Start a new container without specifying anything and see how resolv.conf looks

$ docker run alpine cat /etc/resolv.conf
nameserver 8.8.8.8

Modify the container one, and verify it hasn't affected my host resolv.conf

$ docker run alpine sh -c 'echo "nameserver 123.123.123.123" >> /etc/resolv.conf; cat /etc/resolv.conf;'
nameserver 8.8.8.8
nameserver 123.123.123.123

$ cat /etc/resolv.conf
nameserver 8.8.8.8
nameserver 127.0.0.1

Although docker will create a valid /etc/hosts file too (with the container's hostname automatically in there) it won't copy in the file from the host machine, so the copy-and-mount method you mentioned is your best bet there if you want to copy your host's settings and for it to be writable.

Hope this helps smile x

Offline

Board footer

Powered by FluxBB