我正在尝试构建具有3个容器的Docker应用程序:
不知何故,我尝试从应用程序连接到Web服务时遇到404错误。
Web服务从以下主机的响应正常:
http://localhost:8080/troparo_app/services
通过SOAP UI对其进行了测试,并且工作正常
对于网络客户端(library_app),我无法访问主页:
http://localhost:8090/library-web-1.0-SNAPSHOT/login
但是我得到了404:
org.apache.cxf.transport.http.HTTPException: HTTP response '404: null' when communicating with http://localhost:8080/troparo_app/services/connect/ConnectService
我的docker-compose如下:
# Version of docker-compose
version: '3'
services:
# getting postgres DB
db:
image: postgres:11.1
#container_name: troparo_db
ports:
- 5432:5432
environment:
POSTGRES_USER: ocp
POSTGRES_PASSWORD: 123
POSTGRES_DB: troparo
POSTGRES_INITDB_ARGS: --data-checksums
PGDATA: /var/lib/postgresql/data/pgdata
volumes:
- pg-data:/var/lib/postgresql/data
networks:
- troparo
# getting troparo image
webservice:
image: troparo_app
container_name: troparo_app
build: .
ports:
- 8080:8080
depends_on:
- db
networks:
- troparo
# getting troparo image
webapp:
image: library_app
container_name: library_app
build: ../webo/library/.
ports:
- 8090:8080
depends_on:
- webservice
networks:
- troparo
volumes:
pg-data:
networks:
troparo:
用于library_app的Dockerfile:
FROM tomcat:9.0.14-jre8
RUN rm -rf /usr/local/tomcat/webapps/*
COPY ./library-web/target/library-web-1.0-SNAPSHOT.war /usr/local/tomcat/webapps/library-web-1.0-SNAPSHOT.war
CMD ["catalina.sh","run"]
troparo_app的Dockerfile:
FROM tomcat:9.0.14-jre8
RUN rm -rf /usr/local/tomcat/webapps/*
COPY ./troparo-web/target/troparo_app.war /usr/local/tomcat/webapps/troparo_app.war
CMD ["catalina.sh","run"]
我已连接到客户端容器并ping服务->好的 我尝试了几种组合来连接到Web服务:
http://troparo_app:8080
http://localhost:8080
但到目前为止都失败了。
我是docker的新手,所以我想我在网络中忘记配置某些东西,但到目前为止我仍无法弄清楚,所以如果有人可以提供帮助,我将非常感激! 谢谢