run as user "odoo" lead to writing volume failed
hi I mount a volume directory to /var/lib/odoo,the error shows that access is denied. then I learned about the docker volume machanism, just found neither chmod nor chown affects volume directorys. In my system, when mounting a host directory, the owner will always be root, the mode keeps 755, so the writing won't succeed.
so i think just use root is ok, chown, chmod, and mkdir -p /mnt/extra-addons are not necessary. and use ENTRYPOINT ["bash", "/entrypoint.sh"] you needn't chmod for entrypoint.sh
The volume is already defined in the docker file. I don't see why you would wanna mount the volume to a local folder. Also if you make use of docker-compose for example it will remount the old volume back to the new container if you update it.
Also it's incorrect that the owner will always be root. The thing with docker is that each container has it's own user list. I believe you can fix the folder using this command:
docker exec -u root <odooContainerId> chown odoo:odoo -R /var/lib/odoo
Hey, I got a same problem when I tried to mount Odoo:
grep: /etc/odoo/openerp-server.conf: Permission denied
grep: /etc/odoo/openerp-server.conf: Permission denied
grep: /etc/odoo/openerp-server.conf: Permission denied
grep: /etc/odoo/openerp-server.conf: Permission denied
Traceback (most recent call last):
File "/usr/bin/openerp-server", line 2, in <module>
import openerp
File "/usr/lib/python2.7/dist-packages/openerp/__init__.py", line 61, in <module>
import addons
ImportError: No module named addons
So, I added this in Dockerfile:
RUN chmod +x /etc/odoo/openerp-server.conf
but it does not work.. the result is same above... Host is Synology NAS : Linux version 3.10.102 (root@build4) (gcc version 4.9.3 20150311 (prerelease) (crosstool-NG 1.20.0) )
It happened only NAS. Like ubuntu 16.04 or Mac Sierra, it works very well.
Hi @Spike-Lee.
Dockerfile commands do not work on volumes since the modified file isn't available when the container is being build.
You could try to execute chmod o+r openerp-server.conf on your file that you mounted.
Also I recommend that you use a docker management tool like docker-compose to mount these files. I put some of my frequently used files in this repo.
@thomas15v Thanks for your comment.
Unfortunately, the container is not running because of that, so I cannot execute command.
$ docker-compose up -d
Creating conall_db_1
Creating conall_web_1
$
conall_web_1 is odoo image name. At this moment, conall_web_1is not mounted.
And I have used a docker-compose.yml already:
version: '2'
services:
web:
image: kafkalen20/kafkaodoo9:init
depends_on:
- db
ports:
- "8069:8069"
volumes:
- odoo-web-data:/var/lib/odoo
- ./config:/etc/odoo
- ./addons:/mnt/extra-addons
- ./source:/usr/lib/python2.7/dist-packages/openerp
db:
ports:
- "5432:5432"
image: postgres:9.4
environment:
- POSTGRES_PASSWORD=odoo
- POSTGRES_USER=odoo
- PGDATA=/var/lib/postgresql/data/pgdata
volumes:
- odoo-db-data:/var/lib/postgresql/data/pgdata
volumes:
odoo-web-data:
odoo-db-data:
@Spike-Lee you don't have to execute these commands in the container 😃.
chmod +r -R config addons should do the trick.
Why are you mounting /usr/lib/python2.7/dist-packages/openerp? If your ./source directory is empty this will cause the container to lose all the required odoo files. I actually believe that overwriting that actually caused this problem in the first place.
@thomas15v I have had to install with specific nightly version. Because of that I made a ./source to overwrite. According to your advice I modified Dockerfile.
ENV ODOO_RELEASE 20170427
And delete lines below:
# in Dockerfile
&& echo '4ff504f4b2a49667a0bc8bbca95079305d8108c8 odoo.deb' | sha1sum -c - \
# in docker-compose.yml
- ./source:/usr/lib/python2.7/dist-packages/openerp
Because I don't know how to use sha1sum. Anyway, I did below:
$ chmod +r -R config addons
$ ls -al
total 8
drwxr-xr-x 1 admin users 70 May 16 22:30 .
d---------+ 1 root root 278 May 17 09:15 ..
drwxr-xr-x 1 admin users 0 May 16 20:08 addons
drwxr-xr-x 1 admin users 38 May 16 22:25 config
-rwxrwxrwx 1 admin users 2014 May 16 22:30 Dockerfile
-rwxr-xr-x 1 admin users 1075 May 16 20:12 entrypoint.sh
However it still does not work.
comment update : I tested this on AWS EC2 and it works nicely. The problem is occurred only using Synology NAS..
Still weird tho. Anyhow I also tried exactly what you did and it works fine as well. Weird ... .
You mean tried on Synology NAS? To be precisely, NAS info is
Model : DS916+ DSM version : DSM 6.1.1-15101
To solve the problem, I mailed to Synology technical support.
No, I tried on my ubuntu VM, but for me Linux is Linux so yeah ¯_(ツ)_/¯. Glad you solved the problem 😄.
@thomas15v I have that problem right know, i two versions:
If volumes is - ./rotafilo/addons:/mnt/extra-addons, inside the container i get
odoo@b09e0d9b0a6a:/$ ls mnt/extra-addons/
odoo@b09e0d9b0a6a:/$
If volumes is - ./rotafilo/addons:/var/lib/odoo/addons/11.0, inside the container i get
odoo@b09e0d9b0a6a:/$ ls /var/lib/odoo/addons/11.0
odooplm-11.0 theme_extensia
odoo@b09e0d9b0a6a:/$ ls /var/lib/odoo/addons/11.0/theme_extensia/
ls: cannot open directory '/var/lib/odoo/addons/11.0/theme_extensia/': Permission denied
Why?
solved in comments