这是docker-compose.yml
文件:
version: '3'
services:
############################
# Setup database container #
############################
postgres_db:
image: postgres
restart: always
ports:
- ${POSTGRES_PORT}:${POSTGRES_PORT}
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- PGDATA=/var/lib/postgresql/data/pgdata
- POSTGRES_DB=${POSTGRES_DB}
volumes:
- ./data:/var/lib/postgresql/data
networks:
- db_network
pgadmin:
image: dpage/pgadmin4:4.19
restart: always
ports:
- 8001:8080/tcp
environment:
- PGADMIN_LISTEN_ADDRESS=0.0.0.0
- PGADMIN_LISTEN_PORT=8080
- PGADMIN_DEFAULT_EMAIL=${PGADMIN_DEFAULT_EMAIL}
- PGADMIN_DEFAULT_PASSWORD=${PGADMIN_DEFAULT_PASSWORD}
networks:
- db_network
networks:
db_network:
driver: bridge
Run Code Online (Sandbox Code Playgroud)
.env
同一目录下有一个文件。
# The above refers to the name of the postgres container since using docker-compose
# This is because …
Run Code Online (Sandbox Code Playgroud) 我是 SpringBoot 的新手。我正在尝试创建一个使用 docker 运行的 Spring Boot 应用程序。当我运行这个应用程序时,出现以下错误
org.postgresql.util.PSQLException: FATAL: role "amigoscode" does not exist
Run Code Online (Sandbox Code Playgroud)
我没有任何提示,因为我无法追踪这个错误。角色“amigoscode”已存在。我附在 application.yml 和 docker-compose.yml 下面
应用程序.yml
server:
port: 8080
spring:
application:
name: customer
datasource:
password: password
url: jdbc:postgresql://localhost:5432/customer
username: amigoscode
jpa:
hibernate:
ddl-auto: create-drop
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
format_sql: 'true'
show-sql: 'true'
Run Code Online (Sandbox Code Playgroud)
docker-compose.yml
services:
postgres:
container_name: postgres
image: postgres
environment:
POSTGRES_USER: amigoscode
POSTGRES_PASSWORD: password
PGDATA: /data/postgres
volumes:
- postgres:/data/postgres
ports:
- "5432:5432"
networks:
- postgres
restart: unless-stopped
pgadmin:
container_name: pgadmin
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-pgadmin4@pgadmin.org} …
Run Code Online (Sandbox Code Playgroud)