我正在尝试执行一个"docker-compose “命令。请在我的船坞-撰写文件下面找到。我尝试过使用network_mode:"host",但是它不起作用。我在Linux操作系统上。如果我犯了什么错,请告诉我。
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:"host“的对齐方式时(用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=host模式启动容器?
发布于 2019-09-26 16:22:32
network_mode: host用于与主机共享相同的网络空间。例如,您可以从容器访问运行在Linux上的应用程序。如果要将服务链接到一起,可以使用links或depends_on,如果服务位于不同的主机上,只需创建覆盖网络即可。
https://stackoverflow.com/questions/56521484
复制相似问题