Home

Awesome

Dolibarr on Docker

Docker image for Dolibarr ERP & CRM Open source web suite.

Dolibarr is a modern software package to manage your organization's activity (contacts, quotes, invoices, orders, stocks, agenda, hr, expense reports, accountancy, ecm, manufacturing, ...).

More information

Supported tags

End of support for PHP < 7.4

Dolibarr versions 14 and lower are no more updated

Supported architectures

Linux x86-64 (amd64), ARMv7 32-bit (arm32v7 :warning: MariaDB/Mysql docker images don't support it) and ARMv8 64-bit (arm64v8)

How to run this image ?

This image is based on the official PHP repository and the official Dolibarr repository. It is build using the tools saved in the Dolibarr docker build repository.

This image does not contains database, so you need to link it with a database container. Let's use Docker Compose to integrate it with MariaDB (you can also use MySQL if you prefer):

If you want to have a persistent database and dolibarr data files after reboot or upgrade, you must first create a directory /home/mariadb_data, /home/dolibarr_documents and /home/dolibarr_custom on your host to store persistent files, respectively, of the database, of the Dolibarr document files and of the installed external Dolibarr modules.

mkdir /home/mariadb_data /home/dolibarr_documents /home/dolibarr_custom;

Then, create a docker-compose.yml file as following:

services:
    mariadb:
        image: mariadb:latest
        environment:
            MYSQL_ROOT_PASSWORD: root
            MYSQL_DATABASE: dolibarr
        volumes:
            - /home/mariadb_data:/var/lib/mysql

    web:
        image: dolibarr/dolibarr:latest
        environment:
            DOLI_DB_HOST: mariadb
            DOLI_DB_USER: root
            DOLI_DB_PASSWORD: root
            DOLI_DB_NAME: dolibarr
            DOLI_URL_ROOT: 'http://0.0.0.0'
            DOLI_ADMIN_LOGIN: 'admin'
            DOLI_ADMIN_PASSWORD: 'admin'
            DOLI_INIT_DEMO: 0
            WWW_USER_ID: 1000
            WWW_GROUP_ID: 1000
        ports:
            - "80:80"
        links:
            - mariadb
        volumes:
            - /home/dolibarr_documents:/var/www/documents
            - /home/dolibarr_custom:/var/www/html/custom

Then build and run all services (-d is to run in background)

sudo docker-compose up -d

You can check the web and the mariadb containers are up and see logs with

sudo docker-compose ps

sudo docker-compose logs

Once the log shows that the start is complete, go to http://0.0.0.0 to access to the new Dolibarr installation, first admin login is admin/admin.

Note: If the host port 80 is already used, you can replace "80:80" with "xx:80" where xx a free port on the host. You will be able to access the Dolibarr using the URL http://0.0.0.0:xx

Other examples:

You can find several examples in the examples directory, such as:

Upgrading Dolibarr version and migrating DB

Warning: Only data stored into persistent directories will not be lost after an upgrade of containers.

Remove the install.lock file. The install.lock file is located inside the container volume /var/www/documents.

sudo docker exec nameofwebcontainer bash -c "rm -f /var/www/documents/install.lock"

or

sudo docker exec -it nameofwebcontainer bash

rm -f /var/www/documents/install.lock; exit

Then start an updated version container.

sudo docker-compose pull

sudo docker-compose up -d

sudo docker-compose logs

Ensure that env DOLI_INSTALL_AUTO is set to 1 so it will migrate Database to the new version. You can still use the standard way to upgrade through web interface.

Early support for PostgreSQL

Setting DOLI_DB_TYPE to pgsql enable Dolibarr to run with a PostgreSQL database. When set to use pgsql, Dolibarr must be installed manually on it's first execution:

When setup this way, to upgrade version the use of the web interface is mandatory:

Environment variables summary

You can use the following variables for a better customization of your docker-compose file.

VariableDefault valueDescription
DOLI_INSTALL_AUTO11: The installation will be done during docker first boot
DOLI_INIT_DEMO01: The installation will also load demo data during docker first boot
DOLI_PROD11: Dolibarr will be run in production mode
DOLI_DB_TYPEmysqliType of the DB server (mysqli, pgsql)
DOLI_DB_HOSTmysqlHost name of the MariaDB/MySQL server
DOLI_DB_HOST_PORT3306Host port of the MariaDB/MySQL server
DOLI_DB_USERdoliDatabase user
DOLI_DB_PASSWORDdoli_passDatabase user's password
DOLI_DB_NAMEdolidbDatabase name
DOLI_ADMIN_LOGINadminAdmin's login created on the first boot
DOLI_ADMIN_PASSWORDadminAdmin's initial password created on the first boot
DOLI_URL_ROOThttp://localhostUrl root of the Dolibarr installation
DOLI_ENABLE_MODULESComma-separated list of modules to be activated at install. modUser will always be activated. (Ex: Societe,Facture,Stock)
DOLI_COMPANY_NAMESet the company name of Dolibarr at container init
DOLI_COMPANY_COUNTRYCODESet the company and Dolibarr country at container init. Need 2-letter codes like "FR", "GB", "US",...
PHP_INI_DATE_TIMEZONEUTCDefault timezone on PHP
PHP_INI_MEMORY_LIMIT256MPHP Memory limit
PHP_INI_UPLOAD_MAX_FILESIZE2MPHP Maximum allowed size for uploaded files
PHP_INI_POST_MAX_SIZE8MPHP Maximum size of POST data that PHP will accept.
PHP_INI_ALLOW_URL_FOPEN0Allow URL-aware fopen wrappers
WWW_USER_IDID of user www-data. ID will not changed if leave empty. During a development, it is very practical to put the same ID as the host user.
WWW_GROUP_IDID of group www-data. ID will not changed if leave empty.
DOLI_AUTHdolibarrWhich method is used to connect users, change to ldap or ldap, dolibarr to use LDAP
DOLI_LDAP_HOST127.0.0.1The host of the LDAP server
DOLI_LDAP_PORT389The port of the LDAP server
DOLI_LDAP_VERSION3The version of LDAP to use
DOLI_LDAP_SERVER_TYPEopenldapThe type of LDAP server (openLDAP, Active Directory, eGroupWare)
DOLI_LDAP_LOGIN_ATTRIBUTEuidThe attribute used to bind users
DOLI_LDAP_DNou=users,dc=my-domain,dc=comThe base where to look for users
DOLI_LDAP_FILTERThe filter to authorise users to connect
DOLI_LDAP_BIND_DNThe complete DN of the user with read access on users
DOLI_LDAP_BIND_PASSThe password of the bind user
DOLI_LDAP_DEBUGfalseActivate debug mode
DOLI_CRON01: Enable cron service
DOLI_CRON_KEYSecurity key launch cron jobs
DOLI_CRON_USERDolibarr user used for cron jobs
DOLI_INSTANCE_UNIQUE_IDSecret ID used as a salt / key for some encryption. By default, it is set randomly when the docker container is created.

Some environment variables are compatible with docker secrets behaviour, just add the _FILE suffix to var name and point the value file to read. Environment variables that are compatible with docker secrets:

Add post-deployment and before starting scripts

It is possible to execute *.sh, *.sql and/or *.php custom file at the end of deployment or before starting Apache by mounting volumes. For scripts executed during deployment mount volume in /var/www/scripts/docker-init.d. For scripts executed before Apache stating mount volume in /var/www/scripts/before-starting.d.

\docker-init.d
|- custom_script.sql
|- custom_script.php
|- custom_script.sh

Mount the volumes with compose file :

services:
    mariadb:
        image: mariadb:latest
        environment:
            MYSQL_ROOT_PASSWORD: root
            MYSQL_DATABASE: dolibarr

    web:
        image: dolibarr/dolibarr
        environment:
            DOLI_DB_HOST: mariadb
            DOLI_DB_USER: root
            DOLI_DB_PASSWORD: root
            DOLI_DB_NAME: dolibarr
            DOLI_URL_ROOT: 'http://0.0.0.0'
            DOLI_ADMIN_LOGIN: 'admin'
            DOLI_ADMIN_PASSWORD: 'admin'
            DOLI_INIT_DEMO: 0
            WWW_USER_ID: 1000
            WWW_GROUP_ID: 1000
        volumes :
          - volume-scripts:/var/www/scripts/docker-init.d
          - before-starting-scripts:/var/www/scripts/before-starting.d
        ports:
            - "80:80"
        links:
            - mariadb