简体   繁体   English

Docker Django Postgres 致命:用户“postgres”的密码验证失败

[英]Docker Django Postgres FATAL: password authentication failed for user "postgres

I am dockerizing my Django app.我正在对接我的 Django 应用程序。 My configs are the following:我的配置如下:

csgo.env csgo.env

POSTGRES_NAME='postgres'
POSTGRES_USER='postgres'
POSTGRES_PASSWORD='postgres'
POSTGRES_HOST='postgres_db'
POSTGRES_PORT='5432'

settings.py设置.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': os.getenv('POSTGRES_NAME', 'postgres'),
        'USER': os.getenv('POSTGRES_USER', 'postgres'),
        'PASSWORD': os.getenv('POSTGRES_PASSWORD', 'postgres'),
        'HOST': os.getenv('POSTGRES_HOST', 'postgres_db'),
        'PORT': os.getenv('POSTGRES_PORT', '5432'),
    }
}

docker-compose.yml docker-compose.yml

version: '3'

services:
  web:
    build:
      context: .
      dockerfile: Dockerfile
    env_file:
      - csgo.env
    ports:
      - '8000:8000'
    volumes:
      - .:/code
    depends_on:
      - postgres_db

  postgres_db:
    image: postgres:13
    restart: always
    ports:
      - '5432:5432'
    env_file:
      - csgo.env
    environment:
      - POSTGRES_NAME='postgres'
      - POSTGRES_USER='postgres'
      - POSTGRES_PASSWORD='postgres'
      - POSTGRES_HOST='postgres_db'
      - POSTGRES_PORT='5432'

When I run docker-compose up , I get the typical auth error django.db.utils.OperationalError: FATAL: password authentication failed for user "postgres" and I am really stressed of it.当我运行docker-compose up ,我得到典型的身份验证错误django.db.utils.OperationalError: FATAL: password authentication failed for user "postgres"我真的很紧张。 I have been looking for a typo a day long and haven't figured it out.我一直在寻找一个错字,但一直没有弄清楚。 Please help me to find the missing piece of code or the typo!请帮我找到丢失的代码或错字!

Note: I know that this kind of questions are overflowed on the Internet.注意:我知道这种问题在网上泛滥成灾。 My post is about finding a typo or a mechanical mistake by me.我的帖子是关于发现我的错字或机械错误。 Thanks for understanding and not assigning the post as a duplicate one!感谢您的理解,不要将帖子分配为重复的!

you should set database name in your environment variables:您应该在环境变量中设置数据库名称:

POSTGRES_DB='postgres'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Django Postgres docker-compose 连接错误主要失败:FATAL: password authentication failed for user foobar ERROR: 2 - Django Postgres docker-compose connection error mainly failed: FATAL: password authentication failed for user foobar ERROR: 2 新手需要帮助了解 Docker Postgres django.db.utils.OperationalError: FATAL: password authentication failed for user "postgres" - Newbie needs help understanding Docker Postgres django.db.utils.OperationalError: FATAL: password authentication failed for user "postgres" Docker postgres映像中的用户密码验证失败 - Password authentication failed for user in Docker postgres image Django 连接错误 - django.db.utils.OperationalError:致命:用户“postgres”的密码验证失败 - Django connection error - django.db.utils.OperationalError: FATAL: password authentication failed for user "postgres" 致命:运行 makemigrations 时用户“postgres”的密码身份验证失败 - FATAL: password authentication failed for user "postgres" while running makemigrations django.db.utils.OperationalError: FATAL: password authentication failed for user “postgres” - django.db.utils.OperationalError: FATAL: password authentication failed for user “postgres ” django.db.utils.OperationalError:致命:用户“postgres”的密码认证失败 - django.db.utils.OperationalError: FATAL: password authentication failed for user "postgres" 为什么我会收到此错误? django.db.utils.OperationalError:致命:用户“postgres”的密码验证失败 - why i am receiving this error ? django.db.utils.OperationalError: FATAL: password authentication failed for user “postgres” django postgres密码认证失败 - django postgres password authentication failed 如何使用 django postgres 和 docker-compose 调试密码验证失败 - how to debug password authentication failed with django postgres and docker-compose
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM