我尝试了这个(应该不会返回任何内容):
$ lando ssh -s appserver -u root -c "echo \"10.0.0.132 pds\" >> /etc/hosts"
10.0.0.132 pds >> /etc/hosts
$ lando ssh -s appserver -u root -c "cat /etc/hosts"
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.26.0.2 8da36421fdb0
172.19.0.3 8da36421fdb0
172.18.0.4 8da36421fdb0这表明它不是被添加的。当我以root用户身份进入并在容器中执行此操作时,它就可以工作了。
我想在构建脚本中自动执行此操作。多么?我做错了什么?
显然,这可以通过"docker run --add-host“来完成,但是如何将其包含在.lando.yml文件中呢?
发布于 2019-02-20 23:40:54
/etc/hosts由Docker管理。如果您确实需要添加主机记录,请使用docker run参数:
-- Add -host="“:向/etc/hosts (host:IP)添加一行
文档:https://docs.docker.com/engine/reference/run/#network-settings
发布于 2019-11-22 06:45:13
Lando支持代理设置:(https://docs.lando.dev/config/proxy.html#usage)
proxy:
web:
- mysite.lndo.site
- sub.mysite.lndo.site
- bob.frank.kbox.com
- tippecanoe.tyler.too发布于 2020-04-30 01:41:44
我用"etc/hosts site:lando.dev“搜索了Lando文档,在Services - Build Steps部分找到了可能的解决方案的提示。我还不能尝试,但我看到了一个示例:
services:
servicename:
run_as_root:
- echo "127.0.0.1 mysite.lndo.site" >> /etc/hosts显然,这是将新行附加到服务容器内的/etc/hosts的正确方法。
https://stackoverflow.com/questions/54788034
复制相似问题