docker swarm host网络模式创建任务service 启动失败,一直重复preparing

docker service create 网络模式 host ,用-p 指定端口 不能启动,如下
一直重复 preparing

[root@BizMsTestAlpha test]# docker service create --replicas 1 --network host -p 8081:8081 --name test test
image test:latest could not be accessed on a registry to record
its digest. Each node will access test:latest independently,
possibly leading to different nodes running different
versions of the image.

0bzoexlk04fi53qiwmolq7d6f
overall progress: 0 out of 1 tasks 
1/1: preparing [=================================>                 ] 

去掉-p 指定端口就能正常启动,如下:

[root@BizMsTestAlpha test]# docker service create --replicas 1 --network host  --name test test
image test:latest could not be accessed on a registry to record
its digest. Each node will access test:latest independently,
possibly leading to different nodes running different
versions of the image.

y82wjcxg3ndtevslt9bxbotep
overall progress: 1 out of 1 tasks 
1/1: running   [==================================================>] 
verify: Service converged 
[root@BizMsTestAlpha test]#

swarm service 网络模式host
会直接使用task运行所在主机实际网络和端口,同一主机上运行多个task会存在端口重复绑定导致只能启动一个的问题
没有swarm 集群负载均衡功能

上述2个问题 使用overlay网络模式 不存在
注意:云服务器一般都不支持docker swarm overlay多机集群,存在端口冲突,都使用了 vxlan网络需要udp端口4789

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可以使用Docker Swarm和Docker Compose来创建Zookeeper集群。以下是一个简单的步骤: 1. 创建一个Docker Compose文件,用于定义Zookeeper集群中的服务和配置。例如,可以创建一个名为docker-compose.yml的文件,其中包含以下内容: ``` version: '3' services: zoo1: image: zookeeper restart: always hostname: zoo1 environment: ZOO_MY_ID: 1 ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888 ports: - "2181:2181" - "2888:2888" - "3888:3888" volumes: - ./data/zoo1:/data - ./logs/zoo1:/datalog zoo2: image: zookeeper restart: always hostname: zoo2 environment: ZOO_MY_ID: 2 ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888 ports: - "2182:2181" - "2889:2888" - "3889:3888" volumes: - ./data/zoo2:/data - ./logs/zoo2:/datalog zoo3: image: zookeeper restart: always hostname: zoo3 environment: ZOO_MY_ID: 3 ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888 ports: - "2183:2181" - "2890:2888" - "3890:3888" volumes: - ./data/zoo3:/data - ./logs/zoo3:/datalog ``` 该文件定义了三个Zookeeper实例(zoo1、zoo2和zoo3),每个实例都有自己的ID和端口映射。 2. 使用Docker Swarm启动Zookeeper集群。首先,需要初始化Swarm: ``` docker swarm init ``` 然后,使用以下命令在Swarm中部署Zookeeper集群: ``` docker stack deploy -c docker-compose.yml zookeeper ``` 这将在Swarm中启动三个Zookeeper实例,并配置它们以形成一个集群。 3. 验证集群是否正常工作。可以使用以下命令查看Zookeeper集群的状态: ``` docker exec -it $(docker ps -q -f name=zookeeper_zoo1) /bin/bash zkServer.sh status ``` 该命令将连接到Zookeeper集群中的一个实例(这里是zoo1),并显示集群的状态信息。 这样就可以使用Docker Swarm和Docker Compose创建一个Zookeeper集群。需要注意的是,这仅是一个简单的示例,实际部署可能需要进行更多的配置和调整。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值