我是 docker 的新手。我得到了最新的 docker (18.06.1-ce-win73 (19507)),这个版本会以某种方式修改主机文件,我公司的安全团队阻止任何人修改文件。当我们请求授予权限但他们需要了解Docker为什么修改Hosts文件时。
那么谁能解释一下为什么它在启动时修改文件?
谢谢
最佳答案
我也是 docker 的新手。 但是,阅读这篇文章 (How to update /etc/hosts file in Docker image during "docker build") 我了解到您可以在“docker build”期间更新您的/etc/hosts 文件。
使用较新版本的 docker,这可以通过 docker-compose 及其额外的 hosts directive 来完成(你的版本在这里)
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"
简而言之:在运行时修改容器的/etc/hosts,而不是构建它。
关于windows - Docker- 为什么 docker 更新主机文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52164876/