GithubHelp home page GithubHelp logo

Comments (5)

mjhea0 avatar mjhea0 commented on July 22, 2024 1

Change the environment variables for the db service:

    environment:
      - POSTGRES_USER=hello_django
      - POSTGRES_PASSWORD=hello_django
      - POSTGRES_DB=hello_django_dev

Review the env var section of https://hub.docker.com/_/postgres for more info.

from django-on-docker.

mjhea0 avatar mjhea0 commented on July 22, 2024 1

The volume probably needs to come down. Bring the volume down and try again. (docker-compose down -v)

from django-on-docker.

Emnalyeriar avatar Emnalyeriar commented on July 22, 2024

Hey, thanks for the response but I'm afraid this doesn't solve my problem. According to the link you provided a user and DB with those names should be created. But somehow it still produces the same error.

Here is my config:
.env (this part of env that is visible in django settings)

POSTGRES_DATABASE=django
POSTGRES_USER=django
POSTGRES_PASSWORD=django
POSTGRES_HOST=db
POSTGRES_PORT=5432

docker-compose.yml (env vars set here should create this user and db when image is first run)

...
  db:
    image: postgres:12.0-alpine
    volumes:
     - pg_data:/var/lib/postgresql/data
    environment:
      - POSTGRES_USER=django
      - POSTGRES_PASSWORD=django
      - POSTGRES_DB=django
...

django settings

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': env('POSTGRES_DATABASE', default='django'),
        'USER': env('POSTGRES_USER', default='django'),
        'PASSWORD': env('POSTGRES_PASSWORD', default='django'),
        'HOST': env('POSTGRES_HOST', default='db'),
        'PORT': env('POSTGRES_PORT', default='5432'),
    }
}

Unfortunately I still have this error:
django.db.utils.OperationalError: FATAL: role "django" does not exist

from django-on-docker.

Emnalyeriar avatar Emnalyeriar commented on July 22, 2024

I was pretty sure I did this but before posting here I tried again with:
docker rm $(docker ps -a -q) -f
docker volume prune
and look like it worked, thanks!

from django-on-docker.

DrewBregman avatar DrewBregman commented on July 22, 2024

Hey I'm still getting the same issue trying each step

from django-on-docker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.