我有一个Spring项目并使用application.yml文件来运行配置它。在配置文件中使用占位符并将其作为构建的docker镜像运行时,它不会评估占位符,而在运行没有docker的jar时这可以正常工作。这可能有什么问题?
org.postgresql.util.PSQLException: FATAL: password authentication failed for user "${POSTGRES_DB_USER}"
application.yml
server:
compression:
enabled: true
mime-types: application/json,application/xml,text/html,text/xml,text/plain
context-path: /
port: 8085
logging:
config: config/log4j2-spring.xml
spring:
datasource:
url: jdbc:h2:./data/cdr
username: sa
password:
jpa:
hibernate:
ddl-auto: create-drop
security:
user:
password: secretpassword
---
spring:
profiles: docker
datasource:
url: jdbc:postgresql://postgres/databasename
username: ${POSTGRES_DB_USER}
password: ${POSTGRES_DB_PASS}
搬运工-compose.yml
version: '2'
services:
application:
image: domain.com:3000/application:0-SNAPSHOT
volumes:
- application:/application/logs
ports:
- 8085:8085
links:
- postgres
environment:
PASSWORD: secretpassword
postgres:
image: sameersbn/postgresql:9.5-2
volumes:
- postgres-data:/var/lib/postgresql
environment:
DB_NAME: databasename
DB_USER: user
DB_PASS: secretpassword
volumes:
postgres-data:
driver: local
application-logs:
driver: local
答案 0 :(得分:0)
我想你想要这个:
version: '2'
services:
application:
image: domain.com:3000/application:0-SNAPSHOT
volumes:
- application-logs:/application/logs
ports:
- 8085:8085
environment:
POSTGRES_DB_USER: user
POSTGRES_DB_PASS: secretpassword
postgres:
image: sameersbn/postgresql:9.5-2
volumes:
- postgres-data:/var/lib/postgresql
environment:
DB_NAME: databasename
DB_USER: user
DB_PASS: secretpassword
volumes:
postgres-data: {}
application-logs: {}