Dolibarr Docker Compose SetupΒΆ
This repository contains a Docker Compose setup for running Dolibarr ERP/CRM with an external MariaDB database.
What is Dolibarr?ΒΆ
Dolibarr is a modern, open-source ERP (Enterprise Resource Planning) and CRM (Customer Relationship Management) software designed for small and medium-sized businesses, foundations, and freelancers.
Key Features:ΒΆ
- π₯ Customer/Supplier Management: Complete contact and relationship management
- π° Financial Management: Invoicing, payments, accounting, and reporting
- π¦ Inventory & Stock: Product catalog, stock management, and warehouse operations
- π Sales & Purchasing: Quotes, orders, deliveries, and supplier management
- π¨βπΌ HR & Payroll: Employee management, leave tracking, and expense reports
- π Reporting & Analytics: Built-in reports and business intelligence
- π§ Modular Design: Enable only the modules you need
- π Multi-language: Available in 50+ languages
- π± Responsive: Web-based interface that works on all devices
Why Choose Dolibarr?ΒΆ
- β Open Source: No licensing fees, full control over your data
- β Easy to Use: Intuitive interface designed for non-technical users
- β Highly Customizable: Extensive module system and custom fields
- β Active Community: Large community with regular updates and support
- β Scalable: Grows with your business needs
Official Website: https://www.dolibarr.org
FeaturesΒΆ
- Externalized Database: MariaDB running in a separate container
- Persistent Data: All data persisted using Docker volumes
- Custom Modules: Support for custom Dolibarr modules
- Database Management: Optional phpMyAdmin interface
- Environment Configuration: Fully configurable via environment variables
- Health Checks: Database health monitoring
- Security: Proper network isolation and configurable security settings
Architecture OverviewΒΆ
System ArchitectureΒΆ
graph TB
subgraph "Docker Host"
subgraph "Dolibarr Network"
APP["π Dolibarr Application<br/>Port: 8080"]
DB[("ποΈ MariaDB Database<br/>Port: 3306")]
PMA["π§ phpMyAdmin<br/>Port: 8081"]
end
subgraph "Docker Volumes"
V1[("π dolibarr-html<br/>Application Files")]
V2[("π dolibarr-documents<br/>User Documents")]
V3[("πΎ dolibarr-db-data<br/>Database Storage")]
end
subgraph "Host Directories"
CUSTOM["π¦ ./custom/<br/>Custom Modules"]
LOGS["π ./logs/<br/>Application Logs"]
INIT["βοΈ ./db-init/<br/>DB Init Scripts"]
BACKUP["πΎ ./backups/<br/>Backup Storage"]
end
end
subgraph "External"
USER["π€ User"]
ADMIN["π¨βπΌ Admin"]
EXTDB[("π External Database<br/>MySQL/MariaDB")]
end
USER -->|"HTTP:8080"| APP
ADMIN -->|"HTTP:8081"| PMA
APP --> V1
APP --> V2
APP --> CUSTOM
APP --> LOGS
DB --> V3
DB --> INIT
PMA --> DB
APP -->|"Profile: internal-db"| DB
APP -.->|"Profile: external-db"| EXTDB
style APP fill:#e1f5fe
style DB fill:#f3e5f5
style PMA fill:#fff3e0
style EXTDB fill:#ffebee
Profile-based Database SelectionΒΆ
flowchart LR
START(["Start Dolibarr"]) --> PROFILE{"Select Profile"}
PROFILE -->|"--profile internal-db"| INTERNAL["π Internal Database"]
PROFILE -->|"--profile external-db"| EXTERNAL["π External Database"]
PROFILE -->|"--profile internal-db-tools"| TOOLS["π§ Internal + Tools"]
INTERNAL --> ISERVICES["Services:<br/>β’ Dolibarr App<br/>β’ MariaDB Container"]
EXTERNAL --> ESERVICES["Services:<br/>β’ Dolibarr App<br/>β’ External DB Connection"]
TOOLS --> TSERVICES["Services:<br/>β’ Dolibarr App<br/>β’ MariaDB Container<br/>β’ phpMyAdmin"]
ISERVICES --> RUNNING["β
Running"]
ESERVICES --> RUNNING
TSERVICES --> RUNNING
style INTERNAL fill:#c8e6c9
style EXTERNAL fill:#ffcdd2
style TOOLS fill:#fff9c4
style RUNNING fill:#e8f5e8
Quick StartΒΆ
-
Clone and Setup
-
Configure Environment
-
Update Passwords IMPORTANT: Change the default passwords in
.env
: DB_PASSWORD
- Database user passwordDB_ROOT_PASSWORD
- Database root password-
DOLIBARR_ADMIN_PASSWORD
- Dolibarr admin password -
Start Services
-
Access Dolibarr
- Dolibarr: http://localhost:8080
- phpMyAdmin (optional): http://localhost:8081
Tools AccessΒΆ
Once your services are running, you can access the following tools:
Tool | Purpose | Default URL | Status Check |
---|---|---|---|
π Dolibarr ERP/CRM | Main application interface | http://localhost:8080 | curl -f http://localhost:8080 |
π§ phpMyAdmin | Database management interface | http://localhost:8081 | curl -f http://localhost:8081 |
ποΈ MariaDB Direct | Direct database connection | mysql -h localhost -P 3306 -u dolibarr -p |
mysql -h localhost -P 3306 -e "SELECT 1" |
π Task Runner | Automation commands | task --list |
task --version |
Service-Specific AccessΒΆ
π Dolibarr ApplicationΒΆ
- URL: http://localhost:${DOLIBARR_PORT:-8080}
- Default Login: admin (configurable via
DOLIBARR_ADMIN_LOGIN
) - Default Password: Set via
DOLIBARR_ADMIN_PASSWORD
in.env
- First Setup: Follow the installation wizard on first access
- API Endpoint: http://localhost:${DOLIBARR_PORT:-8080}/api/index.php
- Documentation: Built-in help available in the interface
π§ phpMyAdmin (Internal Database Only)ΒΆ
- URL: http://localhost:${PHPMYADMIN_PORT:-8081}
- Username:
dolibarr
(or your configuredDB_USER
) - Password: Your
DB_PASSWORD
from.env
- Root Access: Username
root
, Password fromDB_ROOT_PASSWORD
- Available: Only when using
--profile internal-db-tools
ποΈ Database Direct AccessΒΆ
- Internal Database:
- External Database: Use your existing database client with configured credentials
π Task AutomationΒΆ
- Command:
task --list
(shows all available tasks) - Examples:
Custom Port ConfigurationΒΆ
To use different ports, update your .env
file:
DOLIBARR_PORT=9080 # Change Dolibarr web port
PHPMYADMIN_PORT=9081 # Change phpMyAdmin port
DB_EXTERNAL_PORT=13306 # Change MariaDB external port
Then access via:
- Dolibarr: http://localhost:9080
- phpMyAdmin: http://localhost:9081
- Database: mysql -h localhost -P 13306 -u dolibarr -p
ConfigurationΒΆ
Environment VariablesΒΆ
Variable | Description | Default |
---|---|---|
DOLIBARR_PORT |
Dolibarr web port | 8080 |
DB_NAME |
Database name | dolibarr |
DB_USER |
Database user | dolibarr |
DB_PASSWORD |
Database password | CHANGE THIS |
DB_ROOT_PASSWORD |
Database root password | CHANGE THIS |
DOLIBARR_ADMIN_LOGIN |
Admin username | admin |
DOLIBARR_ADMIN_PASSWORD |
Admin password | CHANGE THIS |
TIMEZONE |
PHP/Application timezone | Europe/Paris |
Custom ModulesΒΆ
Place custom Dolibarr modules in the ./custom/
directory. They will be mounted to /var/www/html/custom
in the container.
Database InitializationΒΆ
Place SQL initialization scripts in ./db-init/
directory. They will be executed during database creation.
Using an Existing/External DatabaseΒΆ
The setup supports two database modes using Docker Compose profiles: - internal-db: Uses containerized MariaDB (default) - external-db: Connects to your existing database
External Database SetupΒΆ
-
Configure External Database Settings Edit your
.env
file and update the database variables: -
Start with External Database Profile
-
Prepare Your External Database
- Create the database if it doesn't exist
- Ensure the user has proper permissions
- Test connectivity from Docker network
- Verify firewall allows connections from Docker containers
Database Profile CommandsΒΆ
# Internal database (containerized MariaDB)
docker-compose --profile internal-db up -d
# Internal database with phpMyAdmin
docker-compose --profile internal-db --profile internal-db-tools up -d
# External database (your existing database)
docker-compose --profile external-db up -d
Backup & Restore WorkflowΒΆ
flowchart TD
START(["π Start Backup/Restore"]) --> CHOICE{"Operation Type"}
CHOICE -->|"Backup"| BACKUP_TYPE{"Backup Type"}
CHOICE -->|"Restore"| RESTORE_TYPE{"Restore Type"}
BACKUP_TYPE -->|"Complete"| FULL_BACKUP["π¦ Full Backup"]
BACKUP_TYPE -->|"Database Only"| DB_BACKUP["ποΈ Database Backup"]
BACKUP_TYPE -->|"App Data Only"| APP_BACKUP["π App Data Backup"]
FULL_BACKUP --> DB_DUMP["π mysqldump"]
FULL_BACKUP --> APP_TAR["π¦ tar volumes"]
DB_BACKUP --> DB_DUMP
APP_BACKUP --> APP_TAR
DB_DUMP --> COMPRESS["ποΈ gzip compression"]
APP_TAR --> TIMESTAMP["π Add timestamp"]
COMPRESS --> TIMESTAMP
TIMESTAMP --> STORE["πΎ Store in ./backups/"]
RESTORE_TYPE -->|"Database"| DB_RESTORE["π Database Restore"]
RESTORE_TYPE -->|"Application"| APP_RESTORE["π App Data Restore"]
DB_RESTORE --> CHECK_DB{"DB Running?"}
APP_RESTORE --> STOP_SERVICES["βΉοΈ Stop Services"]
CHECK_DB -->|"Yes"| MYSQL_RESTORE["π₯ mysql import"]
CHECK_DB -->|"No"| ERROR1["β Start DB first"]
STOP_SERVICES --> EXTRACT["π¦ Extract tar"]
EXTRACT --> RESTART["π Restart Services"]
MYSQL_RESTORE --> SUCCESS["β
Success"]
RESTART --> SUCCESS
ERROR1 --> FAIL["β Failed"]
style FULL_BACKUP fill:#e3f2fd
style DB_BACKUP fill:#f3e5f5
style APP_BACKUP fill:#fff3e0
style SUCCESS fill:#e8f5e8
style FAIL fill:#ffebee
Task Automation WorkflowΒΆ
stateDiagram-v2
[*] --> TaskSelection
TaskSelection --> ServiceManagement : Service Tasks
TaskSelection --> BackupRestore : Backup/Restore Tasks
TaskSelection --> Maintenance : Maintenance Tasks
TaskSelection --> Utilities : Utility Tasks
state ServiceManagement {
[*] --> StartServices
StartServices --> InternalDB : task start
StartServices --> InternalDBTools : task start-with-tools
StartServices --> ExternalDB : task start-external
InternalDB --> Running
InternalDBTools --> Running
ExternalDB --> Running
Running --> StopServices : task stop
StopServices --> [*]
}
state BackupRestore {
[*] --> BackupChoice
BackupChoice --> CreateBackup : task backup
BackupChoice --> RestoreData : task restore-*
CreateBackup --> BackupComplete
RestoreData --> RestoreComplete
BackupComplete --> [*]
RestoreComplete --> [*]
}
state Maintenance {
[*] --> MaintenanceChoice
MaintenanceChoice --> ResetData : task reset-data
MaintenanceChoice --> Cleanup : task cleanup
MaintenanceChoice --> Update : task update
ResetData --> MaintenanceComplete
Cleanup --> MaintenanceComplete
Update --> MaintenanceComplete
MaintenanceComplete --> [*]
}
state Utilities {
[*] --> UtilityChoice
UtilityChoice --> HealthCheck : task health
UtilityChoice --> ViewLogs : task logs
UtilityChoice --> OpenShell : task shell-*
HealthCheck --> UtilityComplete
ViewLogs --> UtilityComplete
OpenShell --> UtilityComplete
UtilityComplete --> [*]
}
ServiceManagement --> [*]
BackupRestore --> [*]
Maintenance --> [*]
Utilities --> [*]
Task AutomationΒΆ
This project includes organized Taskfiles for common operations. Install Task to use these commands:
Task OrganizationΒΆ
Tasks are organized into separate files in the .taskfile/
directory for better maintainability:
.taskfile/
βββ setup.yml # Initialization and setup tasks
βββ services.yml # Service management (start/stop/status/logs)
βββ config.yml # Dolibarr configuration and module management
βββ backup.yml # Backup and restore operations
βββ maintenance.yml # Cleanup and maintenance tasks
βββ utilities.yml # Utility functions (shell, health checks)
Available Task CategoriesΒΆ
π Setup & InitializationΒΆ
βοΈ Service ManagementΒΆ
task services:start # Start with internal database
task services:start-with-tools # Start with internal database + phpMyAdmin
task services:start-external # Start with external database
task services:stop # Stop all services
task services:status # Show service status
task services:logs # Show logs from all services
task services:logs-app # Show Dolibarr application logs
task services:logs-db # Show database logs
πΎ Backup & RestoreΒΆ
task backup:backup # Create complete backup (database + app data)
task backup:backup-db # Create database backup only
task backup:backup-app # Create application data backup only
task backup:list-backups # List available backups
# Note: Restore tasks require BACKUP_FILE parameter:
# task backup:restore-db BACKUP_FILE=path/to/backup.sql.gz
# task backup:restore-app BACKUP_FILE=path/to/backup.tar.gz
π§Ή MaintenanceΒΆ
task maintenance:cleanup # Clean up Docker resources
task maintenance:update # Update containers to latest versions
task maintenance:reset-data # Reset all data (DANGEROUS)
task maintenance:reset-logs # Clear application logs
task maintenance:reset-custom # Clear custom modules
π§ Configuration ManagementΒΆ
task config:enable-modules # Enable essential business modules (invoices, orders, products, etc.)
task config:enable-api # Enable REST API module with documentation
task config:configure-company # Configure company information and settings
task config:setup-dev-environment # Complete one-command development setup
task config:show-config # Display current configuration and enabled modules
task config:list-modules # List all available modules with status
π§ UtilitiesΒΆ
task utilities:health # Check health of all services
task utilities:shell-app # Open shell in Dolibarr container
task utilities:shell-db # Open MySQL shell in database container
task utilities:permissions # Fix file permissions for Dolibarr
Quick Start with TasksΒΆ
# 1. Initialize the environment
task setup:init
# 2. Start services
task services:start-with-tools
# 3. Check health
task utilities:health
# 4. View logs if needed
task services:logs-app
# 5. Create backup when ready
task backup:backup
Requirements for External Database: - MySQL 5.7+ or MariaDB 10.3+ - UTF8MB4 character set support - User with CREATE, ALTER, INSERT, UPDATE, DELETE, SELECT privileges - Network connectivity from Docker containers
ServicesΒΆ
Dolibarr ApplicationΒΆ
- Image:
dolibarr/dolibarr:latest
- Port: 8080 (configurable)
- Volumes: HTML files, documents, custom modules
MariaDB DatabaseΒΆ
- Image:
mariadb:10.11
- Port: 3306 (configurable)
- Features: Health checks, UTF8MB4 support
- External Access: Available on configured port for external tools
phpMyAdmin (Optional)ΒΆ
- Image:
phpmyadmin/phpmyadmin:latest
- Port: 8081 (configurable)
- Usage: Enable with
docker-compose --profile tools up -d
CommandsΒΆ
Start ServicesΒΆ
# Internal database (containerized MariaDB)
docker-compose --profile internal-db up -d
# Internal database with phpMyAdmin
docker-compose --profile internal-db --profile internal-db-tools up -d
# External database (your existing database)
docker-compose --profile external-db up -d
Stop ServicesΒΆ
View LogsΒΆ
Database BackupΒΆ
# Create backup
docker-compose exec dolibarr-db mysqldump -u root -p dolibarr > backup.sql
# Restore backup
docker-compose exec -T dolibarr-db mysql -u root -p dolibarr < backup.sql
Update ContainersΒΆ
Data PersistenceΒΆ
Data is persisted in the following Docker volumes:
- dolibarr-html
: Web application files
- dolibarr-documents
: Document storage
- dolibarr-db-data
: Database files
Security ConsiderationsΒΆ
Production DeploymentΒΆ
- Change Default Passwords: Update all passwords in
.env
- Restrict Database Access: Remove external database port or restrict to specific IPs
- Use HTTPS: Configure reverse proxy with SSL/TLS
- Environment Security: Use Docker secrets instead of environment variables
- Network Security: Use custom networks and firewall rules
- Regular Updates: Keep containers updated
Network SecurityΒΆ
TroubleshootingΒΆ
Database Connection IssuesΒΆ
# Check database health
docker-compose exec dolibarr-db healthcheck.sh --connect
# Check logs
docker-compose logs dolibarr-db
Permission IssuesΒΆ
Reset InstallationΒΆ
File StructureΒΆ
.
βββ docker-compose.yml # Main compose configuration with profiles
βββ Taskfile.yml # Main task configuration with includes
βββ .taskfile/ # Organized task files
β βββ setup.yml # Initialization and setup tasks
β βββ services.yml # Service management tasks
β βββ backup.yml # Backup and restore operations
β βββ maintenance.yml # Cleanup and maintenance tasks
β βββ utilities.yml # Utility functions and health checks
βββ .env.example # Environment variables template
βββ .env # Environment variables (created from .env.example)
βββ .gitignore # Git ignore patterns
βββ backups/ # Backup storage (created at runtime)
βββ custom/ # Custom Dolibarr modules
β βββ README.md # Custom modules documentation
βββ db-init/ # Database initialization scripts
β βββ README.md # Database init documentation
βββ logs/ # Application logs (created at runtime)
βββ README.md # This file
SupportΒΆ
LicenseΒΆ
This Docker setup is provided as-is. Dolibarr is licensed under GPL v3.