我是docker&docker-compose的新手。我有一个基本的mysql-tomcat docker compose文件,如下所示。我在Windows 10计算机上运行docker。我的Windows目录之一中有我的application.properties文件。 D:/configs/application.properties。如何配置docker-compose或docker,以使每次部署应用程序时该属性文件都被tomcat拾取(在classpath中配置)?我不希望它成为我的docker映像的一部分,因为某些属性特定于机器/开发人员等。
docker-componse up --detach
我的docker-compose.yml
services:
db:
container_name: mysql_mydb
image: mysql:latest
command: --lower_case_table_names=1
environment:
- MYSQL_ROOT_PASSWORD=pass
volumes:
- ./mysql/data/initdb.d:/docker-entrypoint-initdb.d
- ./mysql/data/mysql:/var/lib/mysql
ports:
- 3306:3306
web:
image: tomcat:latest
container_name: tomcat
# Environment variables do not appear to be getting loaded the first time Tomcat starts!
environment:
JDBC_URL: jdbc:mysql://db:3306/my_db?connectTimeout=0&socketTimeout=0&autoReconnect=true
JDBC_USER: root
JDBC_PASS: pass
volumes:
- ./tomcat/webapps:/usr/local/tomcat/webapps
- ./tomcat/logs:/usr/local/tomcat/logs
- ./tomcat/conf:/user/local/tomcat/conf
- ./tomcat/docker-compose-setenv.sh:/usr/local/tomcat/bin/setenv.sh
ports:
- 9090:8080
links:
- db```