Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[9.0] Using odoo+postgresql in Docker Compose Uses Wrong IP Address #57

Closed
medined opened this issue Jun 4, 2016 · 9 comments
Closed

Comments

@medined
Copy link

medined commented Jun 4, 2016

I am trying to use Docker Compose to run odoo. However, the my odoo-web container is not able to connect with my odoo-db container. Here is my docker-compose.yml file:

{noformat}
version: "2"

services:
odoo-db:
restart: on-failure:10
image: postgres:9.4
volumes:
- "d13-odoo:/var/lib/postgresql"
environment:
- POSTGRES_USER=odoo
- POSTGRES_PASSWORD=odoo
odoo-web:
image: odoo:9.0
links:
- odoo-db:db
ports:
- "8069:8069"

volumes:
d13-odoo:
{noformat}

When I run 'docker-compose uo -d', the containers start. And keep running. When I try to connect to the odoo web page using http://192.168.99.100:8069, I see the following error:

{noformat}
2016-06-04 21:09:43,016 1 INFO ? werkzeug: 192.168.99.1 - - [04/Jun/2016 21:09:43] "GET / HTTP/1.1" 500 -
2016-06-04 21:09:43,022 1 ERROR ? werkzeug: Error on request:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 177, in run_wsgi
execute(self.server.app)
File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 165, in execute
application_iter = app(environ, start_response)
File "/usr/lib/python2.7/dist-packages/openerp/service/server.py", line 246, in app
return self.app(e, s)
File "/usr/lib/python2.7/dist-packages/openerp/service/wsgi_server.py", line 184, in application
return application_unproxied(environ, start_response)
File "/usr/lib/python2.7/dist-packages/openerp/service/wsgi_server.py", line 170, in application_unproxied
result = handler(environ, start_response)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1488, in call
return self.dispatch(environ, start_response)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1462, in call
return self.app(environ, start_wrapped)
File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 588, in call
return self.app(environ, start_response)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1617, in dispatch
self.setup_db(httprequest)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1548, in setup_db
httprequest.session.db = db_monodb(httprequest)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1695, in db_monodb
dbs = db_list(True, httprequest)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1669, in db_list
dbs = openerp.service.db.list_dbs(force)
File "/usr/lib/python2.7/dist-packages/openerp/service/db.py", line 307, in list_dbs
with closing(db.cursor()) as cr:
File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 630, in cursor
return Cursor(self.pool, self.dbname, self.dsn, serialized=serialized)
File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 164, in __init

self._cnx = pool.borrow(dsn)
File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 513, in _locked
return fun(self, _args, *_kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 581, in borrow
**connection_info)
File "/usr/lib/python2.7/dist-packages/psycopg2/init.py", line 164, in connect
conn = _connect(dsn, connection_factory=connection_factory, async=async)
OperationalError: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
{noformat}

Please note that I am using Windows. This means that I have a default unix running inside VirtualBox. The IP address of the default container is 192.168.99.100. However, the IP addresses of the two odoo-related containers are 172.18.0.X.

If I use "docker exec -it odoo_odoo-web_1 /bin/bash" to connect to the running odoo-web container, I can use "psql -h db -p 5432 -U odoo -W odoo" to connect to the odoo-db instance and run SQL commands. To me, this means that odoo is pulling the IP address somehow incorrectly. Using 'ping db' inside the container does produce the correct '172.18.0.2' address.

Where is odoo getting "192.168.99.1" from? I don't know enough python to debug this problem. However, I'd be happy to work with someone to resolve this.

Thanks.

P.S. Everything works if I am not using docker-compose.

@devent
Copy link

devent commented Jul 28, 2016

Try to add -e DB_PORT_5432_TCP_ADDR=db

@BitFis
Copy link

BitFis commented Aug 8, 2016

Trying same thing with no success:

version: '2'

services:
  db:
    image: 'postgres:9.4'
    restart: always
    environment:
      - POSTGRES_PASSWORD=odoo
      - POSTGRES_USER=odoo
#    volumes:
#     - './pgdata:/var/lib/postgresql/data'
  web:
    image: 'odoo:9'
    restart: always
    ports:
      - '8069:8069'
    links:
      - db:db
    environment:
      - DB_PORT_5432_TCP_ADDR=db
#    volumes:
#      - './config:/etc/odoo'
#      - './addons:/mnt/extra-addons'
#      - './data:/var/lib/odoo/filestore'

Error:

Show Error Code

Starting dockercomposeodoo_db_1
Recreating dockercomposeodoo_web_1
Attaching to dockercomposeodoo_db_1, dockercomposeodoo_web_1
db_1   | LOG:  database system was shut down at 2016-08-08 12:32:22 UTC
db_1   | LOG:  MultiXact member wraparound protections are now enabled
db_1   | LOG:  autovacuum launcher started
db_1   | LOG:  database system is ready to accept connections
web_1  | 2016-08-08 12:33:23,039 1 INFO ? openerp: OpenERP version 9.0c-20160726
web_1  | 2016-08-08 12:33:23,039 1 INFO ? openerp: addons paths: ['/var/lib/odoo/addons/9.0', u'/mnt/extra-addons', u'/usr/lib/python2.7/dist-packages/openerp/addons']
web_1  | 2016-08-08 12:33:23,039 1 INFO ? openerp: database: postgres@db:
web_1  | 2016-08-08 12:33:23,206 1 INFO ? openerp.service.server: HTTP service (werkzeug) running on 0.0.0.0:8069
web_1  | 2016-08-08 12:33:33,555 1 INFO ? openerp.addons.bus.models.bus: Bus.loop listen imbus on db postgres
web_1  | 2016-08-08 12:33:33,573 1 INFO ? openerp.sql_db: Connection to the database failed
web_1  | 2016-08-08 12:33:33,573 1 ERROR ? openerp.addons.bus.models.bus: Bus.loop error, sleep and retry
web_1  | Traceback (most recent call last):
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/addons/bus/models/bus.py", line 168, in run
web_1  |     self.loop()
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/addons/bus/models/bus.py", line 146, in loop
web_1  |     with openerp.sql_db.db_connect('postgres').cursor() as cr:
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 630, in cursor
web_1  |     return Cursor(self.__pool, self.dbname, self.dsn, serialized=serialized)
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 164, in __init__
web_1  |     self._cnx = pool.borrow(dsn)
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 513, in _locked
web_1  |     return fun(self, *args, **kwargs)
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 581, in borrow
web_1  |     **connection_info)
web_1  |   File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 164, in connect
web_1  |     conn = _connect(dsn, connection_factory=connection_factory, async=async)
web_1  | OperationalError: fe_sendauth: no password supplied
web_1  |
web_1  | 2016-08-08 12:33:33,974 1 INFO ? openerp.addons.report.models.report: Will use the Wkhtmltopdf binary at /usr/local/bin/wkhtmltopdf
web_1  | 2016-08-08 12:33:34,176 1 INFO ? openerp.http: HTTP Configuring static files
web_1  | 2016-08-08 12:33:34,179 1 INFO ? openerp.sql_db: Connection to the database failed
web_1  | 2016-08-08 12:33:34,180 1 INFO ? werkzeug: 172.25.0.1 - - [08/Aug/2016 12:33:34] "GET / HTTP/1.1" 500 -
web_1  | 2016-08-08 12:33:34,184 1 ERROR ? werkzeug: Error on request:
web_1  | Traceback (most recent call last):
web_1  |   File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 177, in run_wsgi
web_1  |     execute(self.server.app)
web_1  |   File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 165, in execute
web_1  |     application_iter = app(environ, start_response)
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/service/server.py", line 246, in app
web_1  |     return self.app(e, s)
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/service/wsgi_server.py", line 184, in application
web_1  |     return application_unproxied(environ, start_response)
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/service/wsgi_server.py", line 170, in application_unproxied
web_1  |     result = handler(environ, start_response)
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1494, in __call__
web_1  |     return self.dispatch(environ, start_response)
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1468, in __call__
web_1  |     return self.app(environ, start_wrapped)
web_1  |   File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 588, in __call__
web_1  |     return self.app(environ, start_response)
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1623, in dispatch
web_1  |     self.setup_db(httprequest)
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1554, in setup_db
web_1  |     httprequest.session.db = db_monodb(httprequest)
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1701, in db_monodb
web_1  |     dbs = db_list(True, httprequest)
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1675, in db_list
web_1  |     dbs = openerp.service.db.list_dbs(force)
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/service/db.py", line 323, in list_dbs
web_1  |     with closing(db.cursor()) as cr:
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 630, in cursor
web_1  |     return Cursor(self.__pool, self.dbname, self.dsn, serialized=serialized)
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 164, in __init__
web_1  |     self._cnx = pool.borrow(dsn)
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 513, in _locked
web_1  |     return fun(self, *args, **kwargs)
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 581, in borrow
web_1  |     **connection_info)
web_1  |   File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 164, in connect
web_1  |     conn = _connect(dsn, connection_factory=connection_factory, async=async)
web_1  | OperationalError: fe_sendauth: no password supplied
web_1  | 2016-08-08 12:34:23,603 1 INFO ? openerp.addons.bus.models.bus: Bus.loop listen imbus on db postgres
web_1  | 2016-08-08 12:34:23,605 1 INFO ? openerp.sql_db: Connection to the database failed
web_1  | 2016-08-08 12:34:23,605 1 ERROR ? openerp.addons.bus.models.bus: Bus.loop error, sleep and retry
web_1  | Traceback (most recent call last):
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/addons/bus/models/bus.py", line 168, in run
web_1  |     self.loop()
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/addons/bus/models/bus.py", line 146, in loop
web_1  |     with openerp.sql_db.db_connect('postgres').cursor() as cr:
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 630, in cursor
web_1  |     return Cursor(self.__pool, self.dbname, self.dsn, serialized=serialized)
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 164, in __init__
web_1  |     self._cnx = pool.borrow(dsn)
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 513, in _locked
web_1  |     return fun(self, *args, **kwargs)
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 581, in borrow
web_1  |     **connection_info)
web_1  |   File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 164, in connect
web_1  |     conn = _connect(dsn, connection_factory=connection_factory, async=async)
web_1  | OperationalError: fe_sendauth: no password supplied
web_1  |
web_1  | 2016-08-08 12:35:13,629 1 INFO ? openerp.addons.bus.models.bus: Bus.loop listen imbus on db postgres
web_1  | 2016-08-08 12:35:13,633 1 INFO ? openerp.sql_db: Connection to the database failed
web_1  | 2016-08-08 12:35:13,634 1 ERROR ? openerp.addons.bus.models.bus: Bus.loop error, sleep and retry
web_1  | Traceback (most recent call last):
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/addons/bus/models/bus.py", line 168, in run
web_1  |     self.loop()
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/addons/bus/models/bus.py", line 146, in loop
web_1  |     with openerp.sql_db.db_connect('postgres').cursor() as cr:
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 630, in cursor
web_1  |     return Cursor(self.__pool, self.dbname, self.dsn, serialized=serialized)
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 164, in __init__
web_1  |     self._cnx = pool.borrow(dsn)
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 513, in _locked
web_1  |     return fun(self, *args, **kwargs)
web_1  |   File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 581, in borrow
web_1  |     **connection_info)
web_1  |   File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 164, in connect
web_1  |     conn = _connect(dsn, connection_factory=connection_factory, async=async)
web_1  | OperationalError: fe_sendauth: no password supplied
web_1  |

@medined didi you find any solution for this?

@devent
Copy link

devent commented Aug 8, 2016

The error is no password supplied
Try to add all of the database specific variables.
I got Odoo 9 to work (except that it shows only an empty page) with (just ignore the variables)

docker run \
--name $(NAME) \
$$DNS_ARG \
-e ODOO_USER_ID=`id -u odoo` \
-e ODOO_GROUP_ID=`id -g odoo` \
-e DB_PORT_5432_TCP_ADDR="postgres_9_4.weave.local" \
-e DB_PORT_5432_TCP_PORT="5432" \
-e DB_ENV_POSTGRES_USER="odoo9" \
-e DB_ENV_POSTGRES_PASSWORD="xxx" \
-v "$(DATA_DIR):/var/lib/odoo" \
$(PORTS) \
-d \
$(IMAGE_NAME) \
openerp-server

@medined
Copy link
Author

medined commented Aug 8, 2016

@BigZ94 I did not get a resolution to this. I just used a regular script to start odoo instead of docker-compose.

@jaredkipe
Copy link

jaredkipe commented Aug 20, 2016

This

is not an issue with Odoo, but rather an issue with docker-compose.

Links does make an alias, e.g. if you get your docker-compose running and then docker-compose exec odoo ping -c 1 you will be able to locate that container.
However, it does not expose any of the environment variables that a usual docker link does. e.g. docker-compose exec odoo env.

The easy solution here is to either set environment variables that /entrypoint.sh is expecting on the odoo service section:

- DB_PORT_5432_TCP_ADDR=db
- DB_PORT_5432_TCP_PORT=5432
- DB_ENV_POSTGRES_USER=odoo
- DB_ENV_POSTGRES_PASSWORD=odoo

OR mount in a config file with with the db host as 'db', user 'odoo', password 'odoo'...

While I have tested the former, I tend to prefer the later as I can run the DB container once with a random password (to create the data data files) and then remove those environment variables from the compose file. (noting that random password in an odoo config file that probably needs modifications like add-on directories anyway).

The former is probably better for 'testing' or other extremely temporary setups.

@medined
Copy link
Author

medined commented Aug 21, 2016

@jaredkipe Thanks for the explanation.

@medined medined closed this as completed Aug 21, 2016
@jaredkipe
Copy link

@medined You're welcome!

@agiratech-murali
Copy link

@medined Hi , I'm facing the same issue like you while trying to dockerize the Odoo13. Can you please tell me how you overcome this issue?
Error: Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

@medined
Copy link
Author

medined commented Apr 7, 2020

@agiratech-murali I'm sorry but I haven't used odoo since 2017 and don't remember.

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

No branches or pull requests

5 participants