Skip to content

Commit 56b46f9

Browse files
committed
Fix install doc not lose persistent directories.
1 parent b48e431 commit 56b46f9

File tree

2 files changed

+129
-21
lines changed

2 files changed

+129
-21
lines changed

README.md

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,16 @@ Dolibarr ERP & CRM is a modern software package to manage your organization's ac
3131

3232
## How to run this image ?
3333

34-
This image is based on the [official PHP repository](https://registry.hub.docker.com/_/php/).
34+
This image is based on the [official PHP repository](https://registry.hub.docker.com/_/php/) and the [official Dolibarr repository](https://github.com/Dolibarr/dolibarr) but doesn't contains database. So you need to link it with a database container.
3535

36-
**Important**: This image don't contains database. So you need to link it with a database container.
36+
Let's use [Docker Compose](https://docs.docker.com/compose/) to integrate it with [MariaDB](https://hub.docker.com/_/mariadb/) (you can also use [MySQL](https://hub.docker.com/_/mysql/) if you prefer):
3737

38-
Let's use [Docker Compose](https://docs.docker.com/compose/) to integrate it with [MariaDB](https://hub.docker.com/_/mariadb/) (you can also use [MySQL](https://hub.docker.com/_/mysql/) if you prefer).
38+
If you want to have a persistent database and dolibarr data files after reboot or upgrade, you must first
39+
create a directory /home/mariadb_data, /home/dolibarr_data and /home/dolibarr_custom on you host to store persistent files.
3940

40-
Create `docker-compose.yml` file as following:
41+
`mkdir /home/mariadb_data; mkdir /home/dolibarr_data;`
42+
43+
Then, create a `docker-compose.yml` file as following:
4144

4245
```yaml
4346
services:
@@ -46,9 +49,11 @@ services:
4649
environment:
4750
MYSQL_ROOT_PASSWORD: root
4851
MYSQL_DATABASE: dolibarr
52+
volumes:
53+
- mariadb_data:/var/lib/mysql
4954

5055
web:
51-
image: dolibarr/dolibarr
56+
image: dolibarr/dolibarr:latest
5257
environment:
5358
DOLI_DB_HOST: mariadb
5459
DOLI_DB_USER: root
@@ -62,15 +67,39 @@ services:
6267
- "80:80"
6368
links:
6469
- mariadb
70+
volumes:
71+
- dolibarr_data:/var/www/documents
72+
- dolibarr_custom:/var/www/html/custom
73+
74+
volumes:
75+
mariadb_data:
76+
driver: local # Define the driver and options under the volume name
77+
driver_opts:
78+
type: none
79+
device: /home/mariadb_data
80+
o: bind
81+
dolibarr_data:
82+
driver: local # Define the driver and options under the volume name
83+
driver_opts:
84+
type: none
85+
device: /home/dolibarr_data
86+
o: bind
87+
dolibarr_custom:
88+
driver: local # Define the driver and options under the volume name
89+
driver_opts:
90+
type: none
91+
device: /home/dolibarr_custom
92+
o: bind
6593
```
6694
6795
Then build and run all services (-d is to run in background)
6896
`sudo docker-compose up -d`
6997

70-
You can check the web and the mariadb containers are up with
98+
You can check the web and the mariadb containers are up and see logs with
7199
`sudo docker-compose ps`
100+
`sudo docker-compose logs`
72101

73-
Now, go to http://0.0.0.0 to access to the new Dolibarr installation, first admin login is admin/admin.
102+
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.
74103

75104
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
76105
able to access the Dolibarr using the URL http://0.0.0.0:xx
@@ -84,14 +113,28 @@ You can find several examples in the `examples` directory, such as:
84113
- [Running Dolibarr with secrets](./examples/with-secrets/dolibarr-with-secrets.md)
85114

86115

87-
## Upgrading version and migrating DB
88-
The `install.lock` file is located inside the container volume `/var/www/documents`.
116+
## Upgrading Dolibarr version and migrating DB
117+
118+
Warning: Only data stored into persistent directories will not be lost after an upgrade of containers.
119+
120+
Remove the `install.lock` file. The `install.lock` file is located inside the container volume `/var/www/documents`.
121+
`sudo docker exec nameofwebcontainer bash -c "rm -f /var/www/documents/install.lock"`
122+
of
123+
`sudo docker exec -it nameofwebcontainer bash`
124+
`rm -f /var/www/documents/install.lock; exit`
125+
89126

90-
Remove the `install.lock` file and start an updated version container. Ensure that env `DOLI_INSTALL_AUTO` is set to `1`. It will migrate Database to the new version.
127+
Then start an updated version container.
128+
`sudo docker-compose pull`
129+
`sudo docker-compose up -d`
130+
`sudo docker-compose logs`
131+
132+
Ensure that env `DOLI_INSTALL_AUTO` is set to `1` so it will migrate Database to the new version.
91133
You can still use the standard way to upgrade through web interface.
92134

93135

94136
## Early support for PostgreSQL
137+
95138
Setting `DOLI_DB_TYPE` to `pgsql` enable Dolibarr to run with a PostgreSQL database.
96139
When set to use `pgsql`, Dolibarr must be installed manually on it's first execution:
97140
- Browse to `http://0.0.0.0/install`;
@@ -107,6 +150,8 @@ When setup this way, to upgrade version the use of the web interface is mandator
107150

108151
## Environment variables summary
109152

153+
You can use the following variables for a better customization of your docker-compose file.
154+
110155
| Variable | Default value | Description |
111156
| ------------------------------- | ------------------------------ | ----------- |
112157
| **DOLI_INSTALL_AUTO** | *1* | 1: The installation will be executed on first boot

README.template

Lines changed: 74 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Dolibarr on Docker
22

3-
Docker image for Dolibarr ERP CRM Open source web suite, with auto installer on first boot.
3+
Docker image for Dolibarr ERP CRM Open source web suite.
4+
45

56
## Supported tags
67
%TAGS%
@@ -9,25 +10,31 @@ Docker image for Dolibarr ERP CRM Open source web suite, with auto installer on
910

1011
**Dolibarr versions 14 and lower are no more updated**
1112

13+
1214
## Supported architectures
1315

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

18+
1619
## What is Dolibarr ?
1720

1821
Dolibarr ERP & CRM is a modern software package to manage your organization's activity (contacts, suppliers, invoices, orders, stocks, agenda, ...).
1922

2023
> [More information](https://github.com/dolibarr/dolibarr)
2124

25+
2226
## How to run this image ?
2327

24-
This image is based on the [official PHP repository](https://registry.hub.docker.com/_/php/).
28+
This image is based on the [official PHP repository](https://registry.hub.docker.com/_/php/) and the [official Dolibarr repository](https://github.com/Dolibarr/dolibarr) but doesn't contains database. So you need to link it with a database container.
29+
30+
Let's use [Docker Compose](https://docs.docker.com/compose/) to integrate it with [MariaDB](https://hub.docker.com/_/mariadb/) (you can also use [MySQL](https://hub.docker.com/_/mysql/) if you prefer):
2531

26-
**Important**: This image don't contains database. So you need to link it with a database container.
32+
If you want to have a persistent database and dolibarr data files after reboot or upgrade, you must first
33+
create a directory /home/mariadb_data, /home/dolibarr_data and /home/dolibarr_custom on you host to store persistent files.
2734

28-
Let's use [Docker Compose](https://docs.docker.com/compose/) to integrate it with [MariaDB](https://hub.docker.com/_/mariadb/) (you can also use [MySQL](https://hub.docker.com/_/mysql/) if you prefer).
35+
`mkdir /home/mariadb_data; mkdir /home/dolibarr_data;`
2936

30-
Create `docker-compose.yml` file as following:
37+
Then, create a `docker-compose.yml` file as following:
3138

3239
```yaml
3340
services:
@@ -36,37 +43,90 @@ services:
3643
environment:
3744
MYSQL_ROOT_PASSWORD: root
3845
MYSQL_DATABASE: dolibarr
46+
volumes:
47+
- mariadb_data:/var/lib/mysql
3948

4049
web:
41-
image: dolibarr/dolibarr
50+
image: dolibarr/dolibarr:latest
4251
environment:
4352
DOLI_DB_HOST: mariadb
4453
DOLI_DB_USER: root
4554
DOLI_DB_PASSWORD: root
4655
DOLI_DB_NAME: dolibarr
4756
DOLI_URL_ROOT: 'http://0.0.0.0'
57+
DOLI_ADMIN_LOGIN: 'admin'
58+
DOLI_ADMIN_PASSWORD: 'admin'
4859
PHP_INI_DATE_TIMEZONE: 'Europe/Paris'
4960
ports:
5061
- "80:80"
5162
links:
5263
- mariadb
64+
volumes:
65+
- dolibarr_data:/var/www/documents
66+
- dolibarr_custom:/var/www/html/custom
67+
68+
volumes:
69+
mariadb_data:
70+
driver: local # Define the driver and options under the volume name
71+
driver_opts:
72+
type: none
73+
device: /home/mariadb_data
74+
o: bind
75+
dolibarr_data:
76+
driver: local # Define the driver and options under the volume name
77+
driver_opts:
78+
type: none
79+
device: /home/dolibarr_data
80+
o: bind
81+
dolibarr_custom:
82+
driver: local # Define the driver and options under the volume name
83+
driver_opts:
84+
type: none
85+
device: /home/dolibarr_custom
86+
o: bind
5387
```
5488

55-
Then run all services `docker-compose up -d`. Now, go to http://0.0.0.0 to access to the new Dolibarr installation.
89+
Then build and run all services (-d is to run in background)
90+
`sudo docker-compose up -d`
91+
92+
You can check the web and the mariadb containers are up and see logs with
93+
`sudo docker-compose ps`
94+
`sudo docker-compose logs`
95+
96+
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.
97+
98+
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
99+
able to access the Dolibarr using the URL http://0.0.0.0:xx
56100

57-
### Other examples
101+
102+
Other examples:
58103

59104
You can find several examples in the `examples` directory, such as:
60105
- [Running Dolibarr with a mysql server](./examples/with-mysql/dolibarr-with-mysql.md)
61106
- [Running Dolibarr with a Traefik reverse proxy](./examples/with-rp-traefik/dolibarr-with-traefik.md)
62107
- [Running Dolibarr with secrets](./examples/with-secrets/dolibarr-with-secrets.md)
63108

64-
## Upgrading version and migrating DB
65-
The `install.lock` file is located inside the container volume `/var/www/documents`.
66109

67-
Remove the `install.lock` file and start an updated version container. Ensure that env `DOLI_INSTALL_AUTO` is set to `1`. It will migrate Database to the new version.
110+
## Upgrading Dolibarr version and migrating DB
111+
112+
Warning: Only data stored into persistent directories will not be lost after an upgrade of containers.
113+
114+
Remove the `install.lock` file. The `install.lock` file is located inside the container volume `/var/www/documents`.
115+
`sudo docker exec nameofwebcontainer bash -c "rm -f /var/www/documents/install.lock"`
116+
of
117+
`sudo docker exec -it nameofwebcontainer bash`
118+
`rm -f /var/www/documents/install.lock; exit`
119+
120+
121+
Then start an updated version container.
122+
`sudo docker-compose pull`
123+
`sudo docker-compose up -d`
124+
`sudo docker-compose logs`
125+
126+
Ensure that env `DOLI_INSTALL_AUTO` is set to `1` so it will migrate Database to the new version.
68127
You can still use the standard way to upgrade through web interface.
69128

129+
70130
## Early support for PostgreSQL
71131
Setting `DOLI_DB_TYPE` to `pgsql` enable Dolibarr to run with a PostgreSQL database.
72132
When set to use `pgsql`, Dolibarr must be installed manually on it's first execution:
@@ -80,8 +140,11 @@ When setup this way, to upgrade version the use of the web interface is mandator
80140
- Upgrade DB;
81141
- Add `install.lock` inside the container volume `/var/www/html/documents` (ex `docker-compose exec services-data_dolibarr_1 /bin/bash -c "touch /var/www/html/documents/install.lock"`).
82142

143+
83144
## Environment variables summary
84145

146+
You can use the following variables for a better customization of your docker-compose file.
147+
85148
| Variable | Default value | Description |
86149
| ------------------------------- | ------------------------------ | ----------- |
87150
| **DOLI_INSTALL_AUTO** | *1* | 1: The installation will be executed on first boot

0 commit comments

Comments
 (0)