我正在尝试运行一个容器,其中我需要将网络驱动程序用作“主机”而不是“桥接器”。我在 Centos 机器上运行它,我的 docker-compose.yml 是
version: '3.4'
services:
testContainer:
build:
context: .
args:
HADOOP_VERSION: 2.6.0
HIVE_VERSION: 1.1.0
image: testcontainer
container_name: testcontainer
hostname: testcontainer
ports:
- 9200:9200
- 9300:9300
- 5601:5601
- 9001:9001
ulimits:
memlock:
soft: -1
hard: -1
networks:
- elknet
networks:
elknet:
driver: host
但当我开火时,我收到以下错误“docker-compose up" :
错误:仅允许一个“主机”网络实例
任何人都可以建议我如何使用 docker-compose.yml 使用主机网络。
另请注意,如果我按照@larsks的建议使用network_host,我仍然收到错误
version: '3.4'
services:
testContainer:
build:
context: .
args:
HADOOP_VERSION: 2.6.0
HIVE_VERSION: 1.1.0
image: testcontainer
container_name: testcontainer
hostname: testcontainer
ports:
- 9200:9200
- 9300:9300
- 5601:5601
- 9001:9001
ulimits:
memlock:
soft: -1
hard: -1
network_mode: host
我收到以下错误
错误:Compose 文件“./docker-compose.yml”无效,因为:
不支持的服务配置选项:“testContainer”
摆脱networks
您的部分docker-compose.yml
,并添加一个网络模式 https://docs.docker.com/compose/compose-file/#network_mode指向您的服务定义:
services:
testContainer:
build:
context: .
args:
HADOOP_VERSION: 2.6.0
HIVE_VERSION: 1.1.0
image: testcontainer
container_name: testcontainer
hostname: testcontainer
ports:
- 9200:9200
- 9300:9300
- 5601:5601
- 9001:9001
ulimits:
memlock:
soft: -1
hard: -1
network_mode: host
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)