I'm new to using docker and am configuring a container.
I am unable to edit /etc/hosts (but need to for some software I'm developing). Auto-edit (via sudo or root) of the file says its on a read only file system. Manual (vim) edit of the file says its read-only and I'm unable to save changes as root (file permissions are rw for owner (root)).
I can however modify other files and add files in /etc.
Is there some reason for this?
Can I change the Docker configuration to allow edit of /etc/hosts?
thanks
This is currently a technical limitation of Docker, and is discussed further at https://github.com/dotcloud/docker/issues/2267.
It will eventually be lifted.
For now, you need to work around it, e.g. by using a custom
dnsmasq
server.UPDATE 2014-09
See @Thomas answer:
Original answer
You can use this hack in the meanwhile
https://unix.stackexchange.com/questions/57459/how-can-i-override-the-etc-hosts-file-at-user-level
In your Dockerfile:
I have recently stumbled upon a need to add an entry into
/etc/hosts
file as well (in order to makesendmail
working).I ended up making it part of the
Dockerfile
'sCMD
declaration like this:So it effectively is not a part of the image, but it is always available after creating a container from the image.
/etc/hosts
is now writable as of Docker 1.2.From Docker's blog: