skip to Main Content

I have bare-metal PostgreSQL server with ip = 192.168.33.12 that i want to use with Odoo.

And I want to run Odoo in Docker and have some kind of persistence.

So, I wan to connect dockered Odoo with my PostgreSQL server.

Here is my docker-compose.yml

version: '3.1'
services:
  web:
    image: odoo:15.0
    ports:
      - "8069:8069"
    volumes:
      - odoo-web-data:/var/lib/odoo
      - ./config:/etc/odoo
      - ./addons:/mnt/extra-addons

volumes:
  odoo-web-data:

On Docker server I have created several directories:

~/odoo/config
~/odoo/addons

docker-compose.yml is in ~/odoo/.

Refers to this guide odoo – Official Image i got odoo.conf in "~/odoo/config" that contains this:

[options]

addons_path = /mnt/extra-addons
data_dir = /var/lib/odoo

admin_passwd = such_a_strong_password
db_host = 192.168.33.12
db_port = 5432
db_user = odooadmin
db_password = one_more_pass
dbfilter = ^odoo-docker-host-0.*$
db_maxconn = 64

So, after running

docker-compose up -d

I can see in Docker logs this entry:

Database connection failure: could not translate host name "db" to address: Name or service not known

2

Answers


  1. Chosen as BEST ANSWER

    I found the solution!

    My config is ok. The problem was in PostgreSQL server network configuration.

    We need tu put this in postgresql.conf:

    # - Connection Settings -
    
    listen_addresses = '*'                  # what IP address(es) to listen on;
    

    And in pg_hba.conf:

    host    all             all             0.0.0.0/0               trust 
    

    or better

    host    all             all             ip_of_odoo_server       trust
    

    Now everything works fine.


  2. well, your docker-compose file is missing the db configurations an example an example could be there. in your case your file could go as following:

    version: '3.1'
    services:
      db:
        image: postgres:14
        user: root
        environment:
          - POSTGRES_USER=odoo
          - POSTGRES_PASSWORD=odoo15@2021      
          - POSTGRES_DB=postgres
        restart: always             # run as a service
        volumes:
            - ./postgresql:/var/lib/postgresql/data
    
      web:
        image: odoo:15.0
        ports:
          - "8069:8069"
        volumes:
          - odoo-web-data:/var/lib/odoo
          - ./config:/etc/odoo
          - ./addons:/mnt/extra-addons
    
    volumes:
      odoo-web-data:
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search