我尝试使用docker-compose
部署我的Web应用,这是配置文件。
version: "3"
networks:
frontend:
backend:
services:
mysql:
image: mysql:5.7
networks:
- backend
volumes:
- ../mysql/my.cnf:/etc/mysql/my.cnf:ro
- ../mysql/data:/var/lib/mysql
- ../mysql/init-files:/docker-entrypoint-initdb.d
restart: always
environment:
MYSQL_USER: root
MYSQL_PASSWORD: root
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: mubo_trm
ports:
- "3306:3306"
myapp:
build: ../myapp
networks:
- frontend
- backend
depends_on:
- mysql
ports:
- "8080:8080"
myapp目录中的Dockerfile是
FROM tomcat:8.0.20-jre8
MAINTAINER me <me@me.com>
COPY ./myapp.war /usr/local/tomcat/webapps/myapp.war
CMD ["catalina.sh", "run"]
然后我尝试运行docker-compose up
,它成功启动了Web容器,我可以从浏览器访问localhost:8080
,但是当我访问localhost:8080/myapp
时,出现了404错误。
如果我没有在docker中部署tomcat,我的应用程序将成功启动。谁能告诉我这是怎么回事?
谢谢!