我的docker-compose.yml
配置文件如下:
version: "2"
services:
spring-cloud-eureka-server01:
#image: java 指定镜像名或者 id,没有就会下载
image: leegoo0820/spring-cloud-eureka-server01-service:0.0.1-SNAPSHOT
volumes: #挂载目录
- "/usr/tmp/data/spring-cloud-eureka-server01"
container_name: spring-cloud-eureka-server_eureka01
build: .
ports: #开放端口
- "8761:8761"
#links:
# - spring-cloud-eureka-server02:discovery
#environment: 设置环境参数
# - spring.profile.active=dev
spring-cloud-eureka-server02:
#image: java 指定镜像名或者 id,没有就会下载
image: leegoo0820/spring-cloud-eureka-server02-service:0.0.1-SNAPSHOT
volumes: #挂载目录
- "/usr/tmp/data/spring-cloud-eureka-server02"
container_name: spring-cloud-eureka-server_eureka02
build: .
ports: #开放端口
- "8762:8762"
spring-cloud-eureka-client01:
#image: java 指定镜像名或者 id,没有就会下载
image: leegoo0820/spring-cloud-eureka-client01:0.0.1-SNAPSHOT
volumes: #挂载目录
- "/usr/tmp/data/spring-cloud-eureka-client01"
#container_name: spring-cloud-eureka-client01
build: .
ports: #开放端口
- "8846:8846"
我现在想水平扩容 spring-cloud-eureka-client01
节点到三个节点,
使用命令 docker-compose scale spring-cloud-eureka-client01=3
但是会报错,如下所示:
WARNING: The scale command is deprecated. Use the up command with the --scale flag instead.
WARNING: The "spring-cloud-eureka-client01" service specifies a port on the host. If multiple containers for this service are created on a single host, the port will clash.
Starting spring-cloud-eureka_spring-cloud-eureka-client01_1 ... done
Creating spring-cloud-eureka_spring-cloud-eureka-client01_2 ... error
Creating spring-cloud-eureka_spring-cloud-eureka-client01_3 ... error
ERROR: for spring-cloud-eureka_spring-cloud-eureka-client01_2 Cannot start service spring-cloud-eureka-client01: b'driver failed programming external connectivity on endpoint spring-cloud-eureka_spring-cloud-eureka-client01_2 (f820f286717a14e11745016963b76ab44622ef7895b1201130129ce1524a159c): Bind for 0.0.0.0:8846 failed: port is already allocated'
ERROR: for spring-cloud-eureka_spring-cloud-eureka-client01_3 Cannot start service spring-cloud-eureka-client01: b'driver failed programming external connectivity on endpoint spring-cloud-eureka_spring-cloud-eureka-client01_3 (7023830ee4f35fe85c75e2a70f276f73fec8ba949d1cfb641a3a19e12f849857): Bind for 0.0.0.0:8846 failed: port is already allocated'
ERROR: Cannot start service spring-cloud-eureka-client01: b'driver failed programming external connectivity on endpoint spring-cloud-eureka_spring-cloud-eureka-client01_2 (f820f286717a14e11745016963b76ab44622ef7895b1201130129ce1524a159c): Bind for 0.0.0.0:8846 failed: port is already allocated'
大概意思就是说扩容的后面几个节点都需要使用 8846 端口,但是 8846 端口已经被第一个占用了,那么我应该怎么样才能够进行扩容呢?
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.