我有一个应用程序运行到嵌入了tomcat的容器中并与MySQL数据库链接
我已通过
运行容器docker-compose up --build -d
,这两个容器已启动,我可以登录到应用程序
但是,当我放上
docker exec -it myapp-mysql bash
然后我用
选择数据库使用dbname;
,我在数据库中看不到任何表
这是我的docker-compose
version: "2"
services:
db:
container_name: myapp-mysql
image: mysql:latest
restart: always
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: XXXXXXXX
MYSQL_DATABASE: XXXXXXX
networks:
app_net:
ipv4_address: A.B.C.D
back-end-java:
container_name: myapp-tomcat
build:
context: .
dockerfile: Dockerfile
restart: always
image: application
ports:
- 8008:8443
links:
- db
networks:
app_net:
ipv4_address: A.B.C.D
networks:
app_net:
driver: bridge
ipam:
driver: default
config:
- subnet: A.B.C.D/24
gateway: A.B.C.D
这是Dockerfile
FROM tomcat:8.0.33-jre8
ADD myapp.war /usr/local/tomcat/webapps/
CMD ["catalina.sh", "run"]
谢谢