【发布时间】:2019-04-30 06:18:20
【问题描述】:
我有 3 个用于 WSO2 apim、身份服务器和 mysql 的 dockerfile。使用 docker-compose 来运行这些。对应的 docker-compose.yml 如下:-
# docker-compose version
version: "3.7"
# services/containers to be run
services:
wso2am:
build: ./apim
image: wso2am:2.6.0
ports:
- "9443:9443"
links:
- mysql-db
- wso2is-km
wso2is-km:
build: ./is-as-km
image: wso2is-km:5.7.0
ports:
- "9444:9444"
links:
- mysql-db
mysql-db:
build: ./mysql
image: mysql:5.7.26
ports:
- "3306:3306"
- "33060:33060"
在不将 h2 数据库更改为 mysql 的情况下运行时,身份服务器/apim 分别在端口 9444/9443 上运行良好。同样在 mysql 中,docker 从 apim/identity 服务器的 datascripts 文件夹中创建了 regdb/apidb sql 数据库。
# Derived from official mysql image (our base image)
FROM mysql:5.7
MAINTAINER Abhilash K R <abhilash.kr@aot-technologies.com>
ENV MYSQL_ROOT_PASSWORD root
# Add a user
ENV MYSQL_USER wso2carbon
ENV MYSQL_PASSWORD wso2carbon
# Add the content of the sql-scripts/ directory to your image
# All scripts in docker-entrypoint-initdb.d/ are automatically
COPY sql-scripts/ /docker-entrypoint-initdb.d
# expose ports
EXPOSE 3306 33060
添加 jdbc 驱动并添加新的 db url 如下:
<datasource>
<name>WSO2_CARBON_DB</name>
<description>The datasource used for registry and user manager</description>
<jndiConfig>
<name>jdbc/WSO2CarbonDB</name>
</jndiConfig>
<definition type="RDBMS">
<configuration>
<url>jdbc:mysql://localhost:3306/regdb</url>
<username>wso2carbon</username>
<password>wso2carbon</password>
<driverClassName>com.mysql.cj.jdbc.Driver</driverClassName>
<maxActive>50</maxActive>
<maxWait>60000</maxWait>
<testOnBorrow>true</testOnBorrow>
<validationQuery>SELECT 1</validationQuery>
<validationInterval>30000</validationInterval>
<defaultAutoCommit>true</defaultAutoCommit>
</configuration>
</definition>
</datasource>
得到如下错误: 认为错误在 url jdbc:mysql://localhost:3306/regdb 处,试图给 dockerhost 的 localhost/ip 也仍然没有工作。
【问题讨论】:
标签: mysql docker wso2 wso2is wso2-am