Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker- Why docker update hosts file?

Tags:

docker

windows

I'm new to docker. I got latest docker (18.06.1-ce-win73 (19507)) and this version will somehow modify the hosts file and my company security team block anyone from modify the file. When we request to grant permission but they need to understand why the Docker modify Hosts file.

So could anyone explain why its modify file during startup?

Thanks

enter image description here

like image 555
tsohtan Avatar asked Oct 28 '22 05:10

tsohtan


1 Answers

i'm new with docker too. But, reading this post (How to update /etc/hosts file in Docker image during "docker build") I understand you can update your /etc/hosts file during "docker build".

With a more recent version of docker, this could be done with docker-compose and its extra hosts directive (your version is here)

Add hostname mappings. Use the same values as the docker run client --add-host parameter (which should already be available for docker 1.8).

extra_hosts:
 - "somehost:162.242.195.82"
 - "otherhost:50.31.209.229"

In short: modify /etc/hosts of your container when running it, not building it.

like image 61
Lucas Eduardo Scrini Avatar answered Nov 15 '22 06:11

Lucas Eduardo Scrini