我有以下 docker-compose,moduleA 如何找到 moduleB 正在運(yùn)行的 IP 或端口,以便它可以對其進(jìn)行 REST 調(diào)用。問題是我應(yīng)該如何配置 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我對端口進(jìn)行了硬編碼,我們是否應(yīng)該注入硬編碼端口或者它是如何工作的?
1 回答

慕桂英546537
TA貢獻(xiàn)1848條經(jīng)驗(yàn) 獲得超10個(gè)贊
您可以moduleA
按照moduleB
與mongo
. 然后在您的環(huán)境中使用相同的內(nèi)容來定義MODULEA_HOST
或在您的屬性文件中使用。
添加回答
舉報(bào)
0/150
提交
取消