So I usually use my container with network mode set to host, however I decided to use docker network create to create a new network device for the container (it is using default bridge mode). Now i want to add a line into /etc/hosts inside the contianer to block access to a single address, I can edit it and it works, however the line deletes itself the moment I have to kill the docker and restart the container. I even docker commit to a new image to make sure it saves, but it seems it doesn’t. Does the container generate /etc/hosts everytime i load the container? If so, how do I set it so the container will generate the additional line? The line is going to be hostname XXX.XXX.XXX?
Details for the setup
Host: Fedora 34/35 using moby-engine
Container: CentOS 7
that will answer your question Keep this command in mind. It gives you helpful information about the container and how its filesystem was built from different merged folders and mounted files.
I tried to search for it on Google like I didn’t know anything about it. Actually, I didn’t remember exactly, because I almost never use it. So I searched for “docker add host”.
I could have searched for “docker add hostname” which would have also worked, but I usually try to use shorter words first, because Google smart enough to search for a part of a word.