我有以下 docker-compose,moduleA 如何找到 moduleB 正在运行的 IP 或端口,以便它可以对其进行 REST 调用。
问题是我应该如何配置 moduleA 获取的 docker 属性是 ModuleB 的 ip 端口
version: "3"
services:
moduleA:
image: jboss/wildfly
ports:
- 9080:8080
- 9990:9990
- 65193:65193
volumes:
- ./ModuleA/target/ModuleA.war:/opt/jboss/wildfly/standalone/deployments/ModuleA.war
environment:
- MONGO_HOST=mongo
- MONGO_PORT=27017
- MONGO_USERNAME=myuser
- MONGO_PASSWORD=mypass
- MONGO_DATABASE=mydb
- MONGO_AUTHDB=admin
command: >
bash -c "/opt/jboss/wildfly/bin/add-user.sh admin Admin#007 --silent && /opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0"
links:
- mongo
depends_on:
- mongo
moduleb:
image: jboss/wildfly
ports:
- 9081:8080
- 9991:9990
- 65194:65193
volumes:
- ./ModuleB/target/ModuleB.war:/opt/jboss/wildfly/standalone/deployments/ModuleB.war
environment:
- MONGO_HOST=mongo
- MONGO_PORT=27017
- MONGO_USERNAME=myuser
- MONGO_PASSWORD=mypass
- MONGO_DATABASE=mydb
command: >
bash -c "/opt/jboss/wildfly/bin/add-user.sh admin Admin#007 --silent && /opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0"
links:
- mongo
depends_on:
- mongo
mongo:
image: mongo:4.0.10
container_name: mongo
environment:
- MONGO_INITDB_ROOT_USERNAME=mongouser
- MONGO_INITDB_ROOT_PASSWORD=mongopass
ports:
- 27017:27017
- 27018:27018
- 27019:27019
我对端口进行了硬编码,我们是否应该注入硬编码端口或者它是如何工作的?
慕桂英546537
相关分类