简体   繁体   English

从 docker 容器内访问主机节点

[英]Access host node from within docker container

I'm setting up Gitlab instance.我正在设置 Gitlab 实例。 And setting up email notifications...并设置 email 通知...

I have the email server postfix running on the host..我在主机上运行了 email 服务器后缀。

In the config gitlab.rb I can set the following email server settings在配置 gitlab.rb 我可以设置以下 email 服务器设置

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "gitlab.simplycreate.online"
gitlab_rails['smtp_port'] = 25

As I can see the smtp_address needs a FQDN and not IP. The problem is Gitlab requires the container hostname set same as the main hosts hostname so I cant use it here??如我所见, smtp_address需要 FQDN 而不是 IP。问题是 Gitlab 需要容器主机名设置为与主主机主机名相同,所以我不能在这里使用它? Is there a way to point it to the host address?有没有办法将它指向主机地址?

If you run your container with -.net=host you can access to your host by localhost .如果您使用-.net=host运行您的容器,您可以通过localhost访问您的主机。

from version 20.10 you can run your container with --add-host=host.docker.internal:host-gateway and access to your host by host.docker.internal从版本20.10开始,您可以使用--add-host=host.docker.internal:host-gateway运行您的容器,并通过host.docker.internal访问您的主机

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

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