【发布时间】:2018-06-08 08:30:45
【问题描述】:
我有以下问题:
我想在我的 docker-compose.yml 文件中定义一个环境变量,如下所示:
services:
nginx:
image: nginx:1.13
container_name: nginx
restart: always
ports:
- "80:80"
- "9090:9090"
volumes:
- ./nginx/conf.d:/etc/nginx/conf.d
- ./nginx/html:/usr/share/nginx/html
webapp:
build: WebApp
container_name: webapp
environment:
- WEBAPPDB=jdbc:mysql://192.168.101.129:3306/webapp?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8
expose:
- "8080"
depends_on:
- nginx
version: '2'
使用 tomcat 部署 webapp 应用程序。我想通过以下方式将变量 WEBAPPDB 使用到 context.xml 文件中:
<Resource
auth="Container"
driverClassName="com.mysql.jdbc.Driver"
type="javax.sql.DataSource"
initialSize="0"
maxActive="10"
maxIdle="5"
maxWait="5000"
minIdle="0"
timeBetweenEvictionRunsMillis="34000"
minEvictableIdleTimeMillis="55000"
testOnBorrow="true"
testWhileIdle="true"
testOnReturn="false"
validationQuery="SELECT 1 FROM dual"
validationInterval="30000"
removeAbandoned="true"
removeAbandonedTimeout="10"
name="jdbc/webapp"
username="username"
password="password"
url="${WEBAPPDB}"
/>
我该怎么做?谢谢你的帮助。
【问题讨论】:
标签: database docker tomcat docker-compose environment-variables