我在Ubuntu 20.04上有vps服务器。请帮我解决这个问题,我被它卡住了,我正在用docker compose用postgresqldb启动我的应用程序,并得到这个错误,我做错了什么?
错误屏幕截图
我的码头组合yml
version: '3.8'
x-restart-policy: &restart_policy
restart: unless-stopped
services:
discord-bot:
<< : *restart_policy
depends_on:
- "postgres"
container_name: discord-bot
build:
context: .
dockerfile: DiscordBot.Application/Dockerfile
environment:
- ENVIRONMENT=Release
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
postgres:
<< : *restart_policy
image: postgres:latest
container_name: discordBot-db
env_file: .env
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 10s
timeout: 5s
retries: 5
command: ["-c", "shared_buffers=512MB", "-c", "max_connections=500"]
expose:
- '5432'
ports:
- '5432:5432'
volumes:
- ./dockervolumes/postgress/srv/postgresql/data:/var/lib/postgresql/data
我的env文件:
POSTGRES_HOST_AUTH_METHOD=trust
POSTGRES_DB=My_dbname
POSTGRES_USER=postgres
POSRGRES_PASSWORD=my_pass
我做错了什么?
postgres:
<< : *restart_policy
image: postgres:latest
container_name: discordBot-db
user: postgres <-- Added this to service !!!
env_file: .env
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 10s
timeout: 5s
retries: 5
command: ["-c", "shared_buffers=512MB", "-c", "max_connections=500"]
expose:
- '5432'
ports:
- '5432:5432'
volumes:
- ./dockervolumes/postgress/srv/postgresql/data:/var/lib/postgresql/data
并运行docker compose up-d(在后台运行(之后,我连接到数据库:docker exec-it postgres psql-U skaarl(在.env文件中指示(SkarlDb(在.ev文件中指示
在我创建了postgres用户并将其更改为超级用户之后,在我完成了docker撰写和docker撰写之后
它起作用了!