odoo / docker

Other
932 stars 1.52k forks source link

How to specify the database name? #394

Open Etren-zz opened 2 years ago

Etren-zz commented 2 years ago

When deploying odoo 15 with docker, I want to connect to an external database. How do I specify the database name when setting the variables of odoo docker? Is the variable NAME used to define the database name?

arabkhemar commented 2 years ago

What do you mean by "external database"? Your postgres server/container is in the same server (where Docker is installed) or in a separate one?

Etren-zz commented 2 years ago

What do you mean by "external database"? Your postgres server/container is in the same server (where Docker is installed) or in a separate one?

Thank you for your reply! I want the odoo container to connect to the external postgreSQL. PostgreSQL is not run in the container, but directly on the host.

arabkhemar commented 2 years ago

Hi @Etren, For connecting to your Postgres Server:

...
odoo:
    image: odoo:15
    environment:
      - HOST=XX.XX.XX.XX
      - PORT=5432 #default
      - USER=odoo
      - PASSWORD=odoo 
...

For database, you have to mount/edit "odoo.conf" and specify it in "db_name"

If it is not clear enough, let me now ;)

Etren-zz commented 2 years ago

Hi @Etren, For connecting to your Postgres Server:

...
odoo:
    image: odoo:15
    environment:
      - HOST=XX.XX.XX.XX
      - PORT=5432 #default
      - USER=odoo
      - PASSWORD=odoo 
...

For database, you have to mount/edit "odoo.conf" and specify it in "db_name"

If it is not clear enough, let me now ;)

Thank you for your reply! I have just started working with Linux systems and postgreSQL. I am using a postgreSQL auxiliary program. When creating a database through a graphical interface, I need to enter the database name, database user name and database password, and database listening address. The host address is 172.17.0.1/16 in the Docker network. My database settings are:

Database_name = my-erp
Database_user = erp-admin
Database_password = password
Listening_address = 172.17.0.0/16

postgreSQL runs directly on the host, and the firewall has released port 5432.

My command to create the odoo container is: docker run -e HOST=172.17.0.1 -e PORT=5432 -e USER=erp-admin -e PASSWORD=password -v /usr/odoo/extra-addons:/mnt/extra-addons -v /usr/odoo/odoo-files:/var/lib/odoo -d -p 8069:8069 --name odoo-15 -t odoo Is there an error in my operation?

Etren-zz commented 2 years ago

”#343 How to connect to the host database?“ It's the same problem.

panha-gms commented 2 years ago

Same problem here for me. I'm trying to connect my odoo container to rds / localhost Postgres but received connection refused. please help me.

stavros-k commented 2 years ago

Hi @Etren, For connecting to your Postgres Server:

...
odoo:
    image: odoo:15
    environment:
      - HOST=XX.XX.XX.XX
      - PORT=5432 #default
      - USER=odoo
      - PASSWORD=odoo 
...

For database, you have to mount/edit "odoo.conf" and specify it in "db_name"

If it is not clear enough, let me now ;)

It would be nice, to be able to specify database name with a variable, just like HOST, USER etc.

kobeumut commented 2 years ago

@arabkhemar How can add database name into odoo.conf before to run docker?

barart commented 2 years ago

same question here... does any one has already do it?

AriesT commented 1 year ago

docker run --name odoo -p 8069:8069 --link postgreSQL:db -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=odoo \ -e POSTGRES_DB=odoo -v /mnt/odoo/data:/var/lib/odoo --restart=always -t -d odoo:15


docker logs -f odoo odoo: Odoo version 15.0-20220902 odoo: Using configuration file at /etc/odoo/odoo.conf odoo: addons paths: ['/usr/lib/python3/dist-packages/odoo/addons', '/mnt/extra-addons'] odoo: database: odoo@172.17.0.3:5432 odoo.addons.base.models.ir_actions_report: Will use the Wkhtmltopdf binary at /usr/local/bin/wkhtmltopdf odoo.service.server: HTTP service (werkzeug) running on afcf79edbe04:8069

deyanira87 commented 1 year ago

@arabkhemar How can add database name into odoo.conf before to run docker?

You can set the db_host parameter in your odoo.conf. For example:

In your compose you can set it like this: version: '3' services: odoo: container_name: ${ODOO_HOST} image: ${ODOO_IMAGE} ports:

and in your odoo.conf (preferable inside the folder ./config) with the other necessary parameters, you just set: db_host = 63.45.12.34 db_user = db_password = db_port = 5432 db_name = dbfilter =

I hope it helps you.

imp1sh commented 1 year ago

I think this needs adjustment. The least you can do is to use a decent database name like "odoo". "postgres"? Imagine having a huge DB cluster an in between all the postgresql databases there is one called "postgres". Other than that I believe the best solution would be to make the database name configurable through a variable.

lathama commented 3 months ago

Something like:

version: '3.1'
services:
  testweb:
    image: odoo:17.0
    depends_on:
      - otherdb
    ports:
      - "8069:8069"
    environment:
      - HOST=otherdb
      - USER=odoo
      - PASSWORD=myodoo
    command: odoo -d customdb
  otherdb:
    image: postgres:15
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_PASSWORD=myodoo
      - POSTGRES_USER=odoo

Hope this helps. @Etren-zz if this answers your question please close this issue.

Special note, the postgresql image needs to be set to db of postgres and then odoo will create and populate the db.