Skip to Content
Menu
This question has been flagged
2 Replies
3362 Views

Hi all,

I am facing the following issue when trying to set up Odoo on my Debian server.

Log file on de database docker mention the following

2023-11-10 09:17:04.692 UTC [499] DETAIL: Role "odoo" does not exist.

Connection matched file "/var/lib/postgresql/data/pgdata/pg_hba.conf" line 128: "host all all all scram-sha-256"

This is my docker-compose.yml

version: '3.3'
networks:
  internal:
    external: false
# backend:
#   external: false


########################### SECRETS

secrets:
  postgres_sql_password:
      file: ${APP_DATA_DIR}/secrets/postgresql_password


services:
#
#

  # ODOO APP 

  odoo:
    image: odoo:16.0
    container_name: odoo
    restart: unless-stopped
    depends_on:
      - db
    ports:
      - 8069:8069
    volumes:
      - ${APP_DATA_DIR}/odoo/app:/var/lib/odoo
      - ${APP_DATA_DIR}/odoo/addons:/mnt/extra-addons
    environment:
      - TZ=$TZ
      - PASSWORD_FILE=/run/secrets/postgresql_password
      - HOST=db
      - USER=odoo
    secrets:
      - postgresql_password
    networks:
      - internal
    links:
      - db

#
#

  # ODOO APP  TRAEFIK OK

  db:
    image: postgres:latest
    container_name: db
    volumes:
      - ${APP_DATA_DIR}/odoo/db:/var/lib/postgresql/data/pgdata
    restart: unless-stopped
    networks:
      - internal
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_PASSWORD=/run/secrets/postgresql_password
      - POSTGRES_USER=odoo
      - PGDATA=/var/lib/postgresql/data/pgdata
    secrets:
      - postgresql_password






Avatar
Discard
Best Answer

This is not typical. The POSTGRES_USER variable is used in conjunction with POSTGRES_PASSWORD to set a user and its password. This variable will create the specified user with superuser power and a database with the same name. If it is not specified, then the default user of postgres will be used (https://hub.docker.com/_/postgres). I suspect that it has to do with how you define your secrets. Your compose deviates from the official Odoo configuration (https://hub.docker.com/_/odoo/). In addition, I would advise to check the logs of your containers as well, besides the 'Role "odoo" does not exist'.


See https://docs.docker.com/engine/swarm/secrets/#use-secrets-in-compose for how to use secrets with docker-compose.


I hope this helps!

Avatar
Discard
Author

Thanks a lot for your response.
I thought of something like that and to test it out, it tried with the simplest user and password, straight in the compose file, not in secrets. But that didn't solve it.
It's really like those variables didn't do their job of creating the user.

Did you try removing the containers and the volumes including content (assuming that they haven't been used yet; i.e., no production database) and then build again?

Author

No I haven't

Best Answer

Create a user named Odoo with permissions to everything in the project on your machine.

Avatar
Discard
Author

This method I described comes from user guides about how to use the docker images. I simply assumed that it would just work. This is how it's supposed to be working. So I need to exec bash the db container and access the postgres console and create a user, is that the solution to this ?

I guess you are right that the user you need to is the postgres one. I also faced permissions conflicts and that is why I also created an Odoo user on the system. It seems tho what you lack is that postgres user. Please take a look at this part, because you are requesting connection via this user:

environment:
- POSTGRES_DB=postgres
- POSTGRES_PASSWORD=/run/secrets/postgresql_password
- POSTGRES_USER=odoo
- PGDATA=/var/lib/postgresql/data/pgdata

Related Posts Replies Views Activity
4
Feb 22
23484
0
Feb 25
1391
2
Jan 25
7875
2
Jan 24
10138
2
Sep 23
6946