Skip to content

How to specify the database name? #394

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
Etren-zz opened this issue Oct 20, 2021 · 13 comments · May be fixed by #426
Open

How to specify the database name? #394

Etren-zz opened this issue Oct 20, 2021 · 13 comments · May be fixed by #426

Comments

@Etren-zz
Copy link

Etren-zz commented Oct 20, 2021

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
Copy link

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
Copy link
Author

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
Copy link

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
Copy link
Author

Etren-zz commented Nov 1, 2021

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
Copy link
Author

Etren-zz commented Nov 1, 2021

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

@panha-gms
Copy link

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
Copy link

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
Copy link

kobeumut commented Mar 31, 2022

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

@barart
Copy link

barart commented Jun 24, 2022

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

@AriesT
Copy link

AriesT commented Sep 12, 2022

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
Copy link

@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.

@mohammed90 mohammed90 linked a pull request Nov 19, 2022 that will close this issue
@imp1sh
Copy link

imp1sh commented Mar 31, 2023

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
Copy link

lathama commented Apr 11, 2024

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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants