【发布时间】:2020-09-07 12:28:43
【问题描述】:
我正在尝试运行一个容器,我需要将网络驱动程序作为“主机”而不是“桥”来使用。我在 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
我收到以下错误
错误:撰写文件“./docker-compose.yml”无效,因为: 服务不支持的配置选项:'testContainer'
【问题讨论】:
标签: docker docker-compose centos7 docker-swarm