简体   繁体   English

修改正在运行的Docker容器的hosts文件

[英]Modifying the hosts file of a running docker container

I need to add an entry to /etc/hosts file of a running container and get it applied same time. 我需要在正在运行的容器的/ etc / hosts文件中添加一个条目,并在同一时间应用它。 I manually modified the hosts file but the change did not get reflected on container. 我手动修改了主机文件,但更改未反映在容器上。 Is there any other we can do this? 还有其他我们可以做到的吗? I want to do this without restarting the container. 我想要执行此操作而无需重新启动容器。

if you check docker inspect {contaner id} as you can see it's different network subnet on your host. 如果您检查docker inspect {contaner id}docker inspect {contaner id}因为您可以看到它是主机上的其他网络子网。 because of docker will create totally sandbox environment for you. 因为docker将为您创建完全沙箱环境。

it will give you random IP when you docker up everytime. 每次您启动Docker时,它将为您提供随机IP。

so I recommend you use docker-compose to help you build your multi-services. 因此,我建议您使用docker-compose帮助您构建多服务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM