SSM*_*SMK 14 docker dockerfile docker-compose docker-machine
我正在尝试执行“ docker-compose up ”命令。请在我的 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
Run Code Online (Sandbox Code Playgroud)
执行后,我收到以下错误
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
Run Code Online (Sandbox Code Playgroud)
我不知道为什么错误消息会显示两次。不确定这是否是预期的
其次,当我改变network_mode的对齐方式时:“host”(按1/2个空格)
ports:
- "3030:80"
network_mode: "host" # please see the change in alignment now
links:
- mongo
Run Code Online (Sandbox Code Playgroud)
我收到以下错误消息
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
Run Code Online (Sandbox Code Playgroud)
如何使用 network=host 模式启动容器?
小智 9
network_mode: host用于与主机共享相同的网络空间。例如,您可能希望从容器访问在 Linux PC 上运行的应用程序。如果要将服务链接在一起,可以使用links, 或depends_on,如果服务位于不同的主机上,则只需创建一个覆盖网络
| 归档时间: |
|
| 查看次数: |
37144 次 |
| 最近记录: |