Odoo is an Python-powered open source ERP, previously called OpenERP (http://www.odoo.com).
This is a Docker image with Odoo and PostgreSQL ready to use.
It is based on Debian stable and includes:
- Odoo 7 or 8 (selected with the repository tag)
- PostgreSQL 9.1
- Supervisor to run both
It only exposes the Odoo web interface at the port 8069.
This is a sample usage, create a container with name "myodoo":
docker pull albertoruibal/odoo:7
docker run -d -p 8069:8069 --name myodoo albertoruibal/odoo:7
and then access the Odoo web interface with your browser at http://localhost:8069
By default, the PostgreSQL data directory is declared as a Docker volume (/var/lib/postgresql), so your database survives container restarts. However, to keep full control over where the data is stored and ensure it is not lost when you remove the container, it is recommended to mount an explicit named or host-mounted volume:
docker run -d -p 8069:8069 \
-v myodoo_pgdata:/var/lib/postgresql \
--name myodoo albertoruibal/odoo:7
To store the data on a host directory instead of a named volume:
docker run -d -p 8069:8069 \
-v /path/on/host/pgdata:/var/lib/postgresql \
--name myodoo albertoruibal/odoo:7
If you also need to preserve Odoo's filestore (uploaded attachments, documents) and logs, add additional volume mounts:
docker run -d -p 8069:8069 \
-v myodoo_pgdata:/var/lib/postgresql \
-v myodoo_filestore:/usr/lib/python2.7/dist-packages/openerp/filestore \
-v myodoo_logs:/var/log/openerp \
--name myodoo albertoruibal/odoo:7
Note: The filestore path differs between Odoo versions. For Odoo 8+ it is typically
/var/lib/odoo. Adjust the path accordingly.
The databases can be created, backed-up and restored from the Odoo web interface accessing to the link in the login page "Manage Databases". The default master password is "admin".
To create a backup of a database from outside the container using pg_dump:
docker exec -t CONTAINER_NAME /bin/su postgres -s /bin/bash -c "pg_dump -Fc DATABASE_NAME" > backup.dump
This produces a PostgreSQL custom-format dump file, the same format generated by the Odoo web interface.
To automate backups with a cron job on the host:
0 2 * * * docker exec -t myodoo /bin/su postgres -s /bin/bash -c "pg_dump -Fc DATABASE_NAME" > /backups/myodoo_$(date +\%Y\%m\%d).dump
If the web interface fails to restore your database in OpenERP 7, you can restore it using the command line:
docker exec -i CONTAINER_NAME /bin/su openerp -s /bin/bash -c "/usr/bin/createdb DATABASE_NAME -E utf8"
docker exec -i CONTAINER_NAME /bin/su openerp -s /bin/bash -c "/usr/bin/pg_restore -c -d DATABASE_NAME" < FILE_TO_RESTORE.dump
Where:
- CONTAINER_NAME: is the name of your Docker container, like "myodoo"
- DATABASE_NAME: name of the PosgreSQL database where you are going to restore the backup
- FILE_TO_RESTORE: a PostgreSQL dump file with the backup (the web interface backup generates this kind of files)
With the docker container running:
sudo docker exec -it openerp7 /bin/bash
migrate.sh DATABASE_NAME
As a result, a DATABASE_NAME_migrated db will be created. That database can be imported in an Odoo v8.