docker icon indicating copy to clipboard operation
docker copied to clipboard

How to specify the database name?

Open Etren-zz opened this issue 2 years ago • 13 comments

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?

Etren-zz avatar Oct 20 '21 07:10 Etren-zz

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?

arabkhemar avatar Oct 20 '21 15:10 arabkhemar

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.

Etren-zz avatar Oct 27 '21 05:10 Etren-zz

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 ;)

arabkhemar avatar Oct 28 '21 09:10 arabkhemar

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 avatar Nov 01 '21 12:11 Etren-zz

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

Etren-zz avatar Nov 01 '21 12:11 Etren-zz

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

panha-gms avatar Jan 20 '22 09:01 panha-gms

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.

stavros-k avatar Mar 06 '22 16:03 stavros-k

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

kobeumut avatar Mar 31 '22 19:03 kobeumut

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

barart avatar Jun 24 '22 18:06 barart

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: [email protected]: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

AriesT avatar Sep 12 '22 13:09 AriesT

@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: - "${ODOO_PORT}:8069" - "${LONGPOLLING_PORT}:8072" volumes: - odoo-data:/var/lib/odoo - ./config:/etc/odoo - ./addons:/mnt/extra-addons networks: default: external: name: net-odoo volumes: odoo-data:

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_USER> db_password = <DB_PASSWORD> db_port = 5432 db_name = dbfilter =

I hope it helps you.

deyanira87 avatar Oct 20 '22 16:10 deyanira87

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.

imp1sh avatar Mar 31 '23 13:03 imp1sh

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.

lathama avatar Apr 11 '24 15:04 lathama