gpt4 book ai didi

docker - 使用图添加到容器的/etc/hosts吗?

转载 作者:行者123 更新时间:2023-12-02 18:25:04 24 4
gpt4 key购买 nike

我正在尝试配置fig,以便可以在不指定完全限定域名的情况下连接到数据库服务器。数据库在裸机上运行(不在docker中)。在主机上,在glinda.local中指定了/etc/hosts,我希望容器模仿此行为(尽管不依赖于主机的配置)。

我在github上找到了this suggestion,但是由于/etc/hosts在只读文件系统上而失败。

所以问题仍然存在,如何在docker容器中将glinda.localfig.yml添加到/etc/hosts

最佳答案

从Docker v1.3.1(我认为)开始,您可以在--add-host中使用docker run选项。不幸的是,这个选项还没有被合并到fig:master,但是有a PR with it。合并(或使用该分支)后,您应该可以通过以下方式使用它:

extra_hosts

Add hostname mappings. Use the same values as the docker client --add-hosts parameter.


> extra_hosts:
> - docker: 162.242.195.82
> - fig: 50.31.209.229

An entry with the ip address and hostname will be created in /etc/hosts inside containers for this service, e.g:


> 162.242.195.82  docker
> 50.31.209.229 fig

关于docker - 使用图添加到容器的/etc/hosts吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28610849/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com