I create a docker container from a centOS 6.5 image. I make some changes to the /etc/hosts file. I then commit the container, and start the new image in a new container, and the /etc/hosts file gets overwritten. Is there a way of keeping the /etc/hosts file as it is?
No. See discussion here.
Docker does different things with /etc/hosts
depending on what option you give to --net
. In the default (bridged) mode, it writes an entry for the hostname and IP address of the container itself. There is no option where it leaves /etc/hosts
as in the source image.
Your options include:
/etc/hosts
at startup, before running the real program/etc/hosts
when you run the container with the --add-host
option.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With