gpt4 book ai didi

Docker 错误 : only one instance of "host" network is allowed

转载 作者:行者123 更新时间:2023-12-02 19:15:25 42 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





How to run docker containers in host network mode using docker-compose?

(1 个回答)


去年关闭。




我正在尝试运行一个容器,我需要将网络驱动程序用户作为“主机”而不是“桥接器”。我在 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 ”时,我收到以下错误:

ERROR: only one instance of "host" network is allowed


任何人都可以建议我如何使用 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
我收到以下错误

ERROR: The Compose file './docker-compose.yml' is invalid because:Unsupported config option for services: 'testContainer'

最佳答案

摆脱networks您的 docker-compose.yml 中的部分,并添加 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

关于Docker 错误 : only one instance of "host" network is allowed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63777655/

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