connection remote database
Hi, how to connect to remote postgres? I add
db_host = $$$.$$$:$$$.$$
db_port = 5432
db_user = peasdasd
db_password = sadasd#
in .conf but cannot connect and see 500 error, my docker-compose is: version: '2' services: odoo12: image: odoo:12.0 ports: - "8071:8069" tty: true command: -- --dev=reload volumes: - ../odoo-restaurantes:/mnt/extra-addons - ./etc:/etc/odoo restart: always # run as a service
Hi @alejuanito
The docker-compose uses official odoo:12.0 image. The container starts Odoo process with DB_ARGS, so changing odoo.conf is not affect. You can check entrypoint.sh:
https://github.com/odoo/docker/blob/c6b79809f0772c419f681889b810ae4aaff8ec37/12.0/entrypoint.sh
Instead of modifying odoo.conf, you should modify the environment of Odoo container by adding something likes to docker-compose.yml: odoo12: image: odoo:12.0 .... environment: - HOST=$$$.$$$:$$$.$$ - PORT=5432 - USER=peasdasd - PASSWORD=sadasd#
I'm having trouble with this as well. Trying
odoo12:
image: odoo:12.0
....
environment:
- HOST=$$$.$$$:$$$.$$
- PORT=5432
- USER=peasdasd
- PASSWORD=sadasd#
isn't working for me as odoo is still trying to connect to localhost.
odoo12_1 | Database connection failure: FATAL: no pg_hba.conf entry for host "${my_localhost_ip}", user "${user}", database "postgres", SSL on
odoo12_1 | FATAL: no pg_hba.conf entry for host "${my_localhost_ip}", user "${user}", database "postgres", SSL off
odoo12_1 |
decapo01_odoo12_1 exited with code 1
Where ${my_localhost_ip} is the ip of the machine I am running docker-compose on and ${user} is the user from both the odoo.conf file and the environment variable user that I am passing in. So it appears that it is finding the user that I'm passing in but not the host and database.
Are there other env variables to set?
Hi @decapo01 ,
The $USER and $PASSWORD in docker-compose.yml is for Postgres database connection. Because you're using remote database, so you have to create this user in Postgres before configuring at Odoo.
The error looks like coming from Postgres. By default, it only allows client to connect locally (localhost). You may need to modify postgresql.conf as the answer in this post:
https://dba.stackexchange.com/questions/83984/connect-to-postgresql-server-fatal-no-pg-hba-conf-entry-for-host
For the env variables, please have a look on the official Odoo and Postgres docker images @ dockerhub.
The error looks like coming from Postgres. By default, it only allows client to connect locally (localhost). You may need to modify postgresql.conf as the answer in this post: https://dba.stackexchange.com/questions/83984/connect-to-postgresql-server-fatal-no-pg-hba-conf-entry-for-host
I think you maybe correct about this however, I'm using a hosted cloud version of postgres called elephantsql where I cannot edit that file.
I do think my problem maybe that odoo is trying to connect to the postgres database by default and I need it to connect to the db name that I've specified. I don't see and environment variable that allows that in this readme https://hub.docker.com/_/odoo/.
Do you know what environment variable I can use to specify the name of the database I want to connect to?
Hi @minhng92 i want to connect my local database, which port, host, db, user and password should I use as a default? this Is my default docker-compose.yaml
services:
db:
image: postgres:9.5
user: root
environment:
- POSTGRES_PASSWORD=odoo
- POSTGRES_USER=odoo
- POSTGRES_DB=postgres
restart: always # run as a service
volumes:
- ./postgresql:/var/lib/postgresql/data
odoo12:
image: odoo:12
user: root
depends_on:
- db
ports:
- "10012:8069"
- "20012:8072" # live chat
tty: true
command: --
# command: odoo scaffold /mnt/extra-addons/test_module
environment:
- HOST=db
- USER=odoo
- PASSWORD=odoo
volumes:
#- /etc/timezone:/etc/timezone:ro
#- /etc/localtime:/etc/localtime:ro
# - ./entrypoint.sh:/entrypoint.sh # if you want to install additional Python packages, uncomment this line!
- ./addons:/mnt/extra-addons
- ./etc:/etc/odoo
restart: always # run as a service