gpt4 book ai didi

docker - 如何制作Network_Mode : "host" work in docker-compose. yml文件

转载 作者:行者123 更新时间:2023-12-02 17:35:26 24 4
gpt4 key购买 nike

我正在尝试执行“ docker-compose up ”命令。请在下面找到我的docker-compose文件。我尝试了 network_mode:“主机” ,但是它不起作用。我在Linux OS上。要求您让我知道我是否犯了任何错误。

version: '3.6'
services:
mongo:
image: "mongo:latest"
container_name: ohif-mongo
ports:
- "27017:27017"

viewer:
image: ohif/viewer:latest
container_name: ohif-viewer
ports:
- "3030:80"
network_mode: "host" # please make note of the alignment
links:
- mongo
environment:
- MONGO_URL=mongodb://mongo:27017/ohif
extra_hosts:
- "pacsIP:172.xx.xxx.xxx"
volumes:
- ./dockersupport-app.json:/app/app.json

执行后,出现以下错误
ERROR: for 8f4c3de7e3a3_ohif-viewer  Cannot create container for service viewer: conflicting options: host type networking can't be used with links. This would result in undefined behavior
ERROR: for viewer Cannot create container for service viewer: conflicting options: host type networking can't be used with links. This would result in undefined behavior

我不知道为什么错误消息会显示两次。不确定这是否是预期的

其次,当我更改network_mode的对齐方式时:“主机”(减1/2个空格)
  ports:
- "3030:80"
network_mode: "host" # please see the change in alignment now
links:
- mongo

我收到以下错误消息
ERROR: yaml.parser.ParserError: while parsing a block mapping
in "./docker-compose.yml", line 10, column 5
expected <block end>, but found '<block mapping start>'
in "./docker-compose.yml", line 14, column 6

如何以网络=主机模式启动容器?

最佳答案

network_mode: host用于与主机共享相同的网络空间。例如,您可能想从容器访问Linux PC上运行的应用程序。
如果要将服务链接在一起,则可以使用linksdepends_on,并且如果服务位于不同的主机上,则只需创建一个覆盖网络即可

关于docker - 如何制作Network_Mode : "host" work in docker-compose. yml文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56521484/

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