Skip to main content

Troubleshooting Odoo Docker and Docker Compose

I figured out some good debugging methods that both solved this problem and seem generally useful for figuring out Docker persistent data volume issues.

Test 1: can the container work with an empty Docker volume?

This is a really easy test: just create a new Docker volume and pass that in your -v argument (instead of a host directory absolute path):

sudo docker volume create hello
sudo docker run -v hello:/var/lib/odoo -p 8069:8069 --name odoo --link db:db -t odoo

The odoo container immediately worked successfully this way (i.e. my web browswer was able to connect to the Odoo server). This showed that it could work fine with an (initially) empty data directory. The obvious question then is why it didn't work with an empty host-directory volume. I had read that Docker containers can be persnickety about UID/GID ownership, so my next question was how do I figure out what it expects.

Test 2: inspect the running container's file system

I used docker exec to get an interactive bash shell in the running container:

sudo docker exec -ti odoo bash

Inside this shell I then looked at the data directory ownership, to get numeric UID and GID values:

ls -dn /var/lib/odoo

This showed me the UID/GID values were 101:101. (You can exit from this shell by just typing Control-D)

Test 3: re-run container with matching host-directory UID:GID

I then changed the ownership of my host directory to 101:101 and re-ran the odoo container with my host-directory mount:

sudo chown 101:101 /tmp/odoo
sudo docker stop odoo
sudo docker rm odoo
sudo docker run -v /tmp/odoo:/var/lib/odoo -p 8069:8069 --name odoo --link db:db -t odoo

Success! Finally the odoo container worked properly with a host-directory mount. While it's annoying the Odoo docker docs don't mention anything about this, it's easy to debug if you know how to use these basic tests.

https://stackoverflow.com/questions/54187785/how-to-debug-persistent-data-volume-mount-for-docker-odoo-container