I have tried so many methods to create an Odoo application using Docker container, even asking Claude.ai and Copilot. All of them did not work except one, from a blog from Mr. Saw. However, I wanted to change the password, but it did not worked. Here is the original YAML file
services:
db:
image: postgres:16
ports:
- "5432:5432"
environment:
- POSTGRES_USER=odoo
- POSTGRES_PASSWORD=odoo
- PGDATA=/var/lib/postgresql/data/pgdata
volumes:
- odoo-db-data:/var/lib/postgresql/data
odoo18:
image: odoo:18.0
depends_on:
- db
ports:
- "8068:8069"
volumes:
- odoo-web-data:/var/lib/odoo
- ./config:/etc/odoo
- ./addons:/mnt/extra-addons
command: odoo -d odoo_db -i base --db_user=odoo --db_password=odoo --db_host=db
volumes:
odoo-web-data:
odoo-db-data:
I tried to changed the postgres password like
- POSTGRES_PASSWORD=complexpassword
and
command: odoo -d odoo_db -i base --db_user=odoo --db_password=complexpassword --db_host=db
If I changed the password other than odoo, the container will not start, and the logs will show this error:
Database connection failure: connection to server at "db" (172.18.0.2), port 5432 failed: FATAL: password authentication failed for user "odoo"
Why is that so? How can I change the "default" password? Can I put the password in a odoo.conf?
Have a look at the documentation for the postgres docker image
https://hub.docker.com/_/postgres#environment-variables
specifically where it says
\> Warning: the Docker specific variables will only have an effect if you start the container with a data directory that is empty; any pre-existing database will be left untouched on container startup.
So the first time you start the postgres instance the password will be set, after that if you want to change it you need to drop into the postgres instance docker exec -it $container_name /bin/bash and then change the password for the odoo user as shown here https://www.postgresql.org/docs/8.0/sql-alteruser.html