Open ArturBumbu opened 6 years ago
I've encountered what looks like a similar issue and it appears to involve permissions of docker volume directories on the host. Without doing anything special, containerized odoo user doesn't have access to write to my volume directories and install will fail with similar log message, files do not get created in my web:/var/lib/odoo
volume and nginx-proxy will serve up "502 Bad Gateway".
Other docker images, like postgres for example, set permissions of volume directories properly from within the container at initial runtime -- maybe because the entrypoint script launches as root so that directory/file permissions can be changed before switching to executing as a non-root user.
Here's what I use to navigate and automate this, and also create the initial odoo config file by copying it from the odoo docker image. Before launching odoo initially (I'm using docker-compose with odoo & postgres), run this to create volume directories on the host server with permissions of the containerized odoo user:
DATA_DIR=/srv/odoo.mydomain.com
IMAGE_ODOO=odoo:11
# create volume directories with permissions of the odoo user within the container
# copy initial config file from the docker image
mkdir -p ${DATA_DIR}
chmod 777 ${DATA_DIR}
docker run -it --rm \
-v ${DATA_DIR}:/x \
--entrypoint /bin/bash \
${IMAGE_ODOO} \
-c 'cp -a /etc/odoo /x/config; cp -a /var/lib/odoo /x/web; cp -a /mnt/extra-addons /x/addons'
chmod 755 ${DATA_DIR}
my odoo volumes in docker-compose.yml:
volumes:
- ${DATA_DIR}/addons:/mnt/extra-addons
- ${DATA_DIR}/config:/etc/odoo
- ${DATA_DIR}/web:/var/lib/odoo
Hi @sensorii
Thanks for this solution but don't you have to synchronize your data folder again later if you want to have your data realy persistent ?
What the usage of /var/lib/odoo
folder ?
@weeger, this could have changed or been fixed by now. At the time, /var/lib/odoo
was the default value for data_dir
in odoo.conf
. With this solution, all data is persistent and exported with volumes. The initial docker run
(which looks like a lot) is only initializing some volume directories on the host using the correct permissions of the user that runs in the odoo container as well as getting the default/initial odoo.conf
from the docker image (vs having to otherwise manually get it onto the host). After running that, docker-compose
then runs the odoo container(s) detached in background.
Not fixed. When mounting volumes with docker run -v
incorrect permissions are set on the host for /var/lib/odoo
and the container just stuck.
@ArturBumbu is this still an issue in 2024? Can you close if not needed?
I am still encountering this issue however my instance is using odoo17 not odoo11 so I am not sure if that makes this applicable to or not.
Can anyone share methods of reproducing this? Docker commands, Docker compose files?
Can someone show that their odoo.conf is not readable. Here is a fast test I did
lathama@42:~$ docker run -it --entrypoint /bin/bash -v ~/tmp/odoo:/etc/odoo odoo:17
odoo@714ba77fce77:/$ ls -lha /etc/odoo/odoo.conf
-rw-r--r-- 1 1000 1000 1.1K Apr 27 19:30 /etc/odoo/odoo.conf
odoo@714ba77fce77:/$ exit
exit
lathama@42:~$ docker run -it --entrypoint /bin/bash odoo:17
odoo@8b6089c664c7:/$ ls -lha /etc/odoo/odoo.conf
-rw-rw-r-- 1 odoo root 816 Apr 16 21:51 /etc/odoo/odoo.conf
odoo@8b6089c664c7:/$ exit
exit
lathama@42:~$
ubuntu@vm2:/tmp$ sudo docker run -it --entrypoint /bin/bash -v ~/tmp/odoo:/etc/odoo odoo:17.0 odoo@2df6d8509179:/$ ls -lha /etc/odoo/odoo.conf ls: cannot access '/etc/odoo/odoo.conf': No such file or directory odoo@2df6d8509179:/$
@aitmlouk Would you kindly docker pull odoo:17.0
and see if you are able to reproduce with latest?
On a related note, why are you using sudo
to run docker? That absolutely smells like the sort of thing that could result in file access issues.
@aitmlouk Would you kindly
docker pull odoo:17.0
and see if you are able to reproduce with latest?On a related note, why are you using
sudo
to run docker? That absolutely smells like the sort of thing that could result in file access issues.
Becuase they're probably not a member of the docker group.
The logs from docker container are below:
grep: /etc/odoo/odoo.conf: No such file or directory grep: /etc/odoo/odoo.conf: No such file or directory grep: /etc/odoo/odoo.conf: No such file or directory grep: /etc/odoo/odoo.conf: No such file or directory 2018-03-22 22:36:04,827 1 INFO ? odoo: Odoo version 11.0-20180122 2018-03-22 22:36:04,827 1 INFO ? odoo: addons paths: ['/usr/lib/python3/dist-packages/odoo/addons'] 2018-03-22 22:36:04,827 1 INFO ? odoo: database: odoo@db:5432 2018-03-22 22:36:04,836 1 INFO ? odoo.service.server: HTTP service (werkzeug) running on 0.0.0.0:8069 2018-03-22 22:36:04,920 1 INFO ? odoo.addons.base.ir.ir_actions_report: Will use the Wkhtmltopdf binary at /usr/local/bin/wkhtmltopdf 2018-03-22 22:37:12,335 1 INFO ? odoo.http: HTTP Configuring static files