【发布时间】:2020-12-21 17:01:38
【问题描述】:
【问题讨论】:
标签: spring-boot docker jhipster
【问题讨论】:
标签: spring-boot docker jhipster
通过在 docker run 命令中添加 - - net=host 将 docker 端口公开给主机网络。然后您的应用程序可以像 localhost:YourPort 一样访问它
例如
Docker run mysql --net=host
【讨论】:
我找到了办法。
下载 postgres 镜像:docker pull postgres:alpine
创建一个 docker 数据库并确定从 docker 连接到哪个端口: docker run --name myUserName -e POSTGRES_PASSWORD=myPassword -d -p 5432:5432 postgres:alpine
进入 docker 容器:docker exec -it containerID bash
连接到 postresql:psql -U postgres myUserName
创建数据库:create database databaseName;
现在在 docker 之外,在您的 application.yml 中:
数据源:
类型:com.zaxxer.hikari.HikariDataSource
网址:jdbc:postgresql://localhost:5432/bnksearch?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true
用户名:postgres
密码:postgres
光:
poolName: Hikari
auto-commit: false
data-source-properties:
cachePrepStmts: true
prepStmtCacheSize: 250
prepStmtCacheSqlLimit: 2048
useServerPrepStmts: true
【讨论】: