tuxgasy/docker-dolibarr

Use external MySQL docker container

aliceout opened this issue · 4 comments

This is not a bug, but a request for help

I want to use Dolibarr with an external mariadb container (in order to share it with several containers), but despite several attempts for two days, the Dolibarr container tells me (in the logs) that it is waiting for the database.

Waiting that SQL database is up ...

Thanks in advance for your help

I use this following configurations :

MariaDB container

version: 3.7

services:
  mariadb:
    image: lscr.io/linuxserver/mariadb:latest
    container_name: mariadb
    environment:
      - PUID=1000
      - PGID=1000
      - MYSQL_ROOT_PASSWORD=root
      - TZ=Europe/London
    volumes:
      - ./config:/config
    ports:
      - 3308:3306
    restart: always
    networks:
      - network
networks:
  network:

Dolibarr container :

version: 3.7

services:
  web:
    image: tuxgasy/dolibarr:latest
    container_name: dolibarr
    environment:
      DOLI_DB_HOST: mariadb
      DOLI_DB_USER: root
      DOLI_DB_PASSWORD: root
      DOLI_DB_NAME: dolibarr
      DOLI_ADMIN_LOGIN: admin
      DOLI_ADMIN_PASSWORD: password
      DOLI_URL_ROOT: https://dolibarr.xxxx.xx
    ports:
      - 8095:80
    restart: always
    networks:
      - mariadb_network
networks:
  mariadb_network:
     external: true

Hi, try this :

version: 3.7

services:
  mariadb:
    image: lscr.io/linuxserver/mariadb:latest
    container_name: mariadb
    environment:
      - PUID=1000
      - PGID=1000
      - MYSQL_ROOT_PASSWORD=root
      - TZ=Europe/London
    volumes:
      - ./config:/config
    ports:
      - 3308:3306
    restart: always
    networks:
      - db
  web:
    image: tuxgasy/dolibarr:latest
    container_name: dolibarr
    environment:
      DOLI_DB_HOST: mariadb
      DOLI_DB_USER: root
      DOLI_DB_PASSWORD: root
      DOLI_DB_NAME: dolibarr
      DOLI_ADMIN_LOGIN: admin
      DOLI_ADMIN_PASSWORD: password
      DOLI_URL_ROOT: https://dolibarr.xxxx.xx
    ports:
      - 8095:80
    restart: always
    networks:
      - db
networks:
  db:

Why not on the same stack as above?
It is necessary to look if the names between stacks correspond well.
Obviously, the two containers can't communicate with each other. This is not a problem related to the project, but a Docker configuration problem.

Hi @LaplancheMaxime

Thank you for your answer

Indeed, as I said in my message, it is not a problem related to the project, because when I do as you suggest everything works fine.
I was rather asking for a hand.

In fact I want to separate the two, because I want to have a separate MariaDb container to be able to share it with other containers, and avoid having 5 mariadb instances running simultaneously (management, resource consumption, etc.)

I've looked at the docker documentation, and I can't figure out where the bug is

hi @Yamakuni,

I got similar issues on other projects, need you to create a network outside compose, and use it as external network.

Try to create a network outside using the docker network command, and use it into your both compose with external: true

@Liliyce You can use config like this:

docker-compose-mariadb.yml

version: '3.3'
services:
  mariadb:
    image: mariadb:10.7.3
    container_name: mariadb1073
    hostname: mariadb1073
    restart: always
    environment:
      - MARIADB_ROOT_HOST=localhost
      - MARIADB_ROOT_PASSWORD=xxxxxxxxxxxxxxxxxxxxxxxxxxxx
      - MARIADB_MYSQL_LOCALHOST_USER=yes
    ports:
      - xx.xx.xx.xx:3306:3306
    volumes:
      - /var/lib/mariadb/10.7.3:/var/lib/mysql/

And in docker-compose-dolibarr.yml

version: "3"
services:
  dolibarr:
    image: tuxgasy/dolibarr:16.0.3
    container_name: dolibarr
    hostname: dolibarr
    environment:
      DOLI_DB_HOST: mariadb
      DOLI_DB_HOST_PORT: 3306
      DOLI_DB_USER: xxxxxxxxxxxx
      DOLI_DB_PASSWORD: xxxxxxxxxxxx
      DOLI_DB_NAME: xxxxxxxxxxxx
      DOLI_URL_ROOT: 'https://xxxxxxxxxxxx'
      PHP_INI_DATE_TIMEZONE: 'Europe/Paris'
      DOLI_INSTALL_AUTO: 1
    ports:
      - "xx.xx.xx.xx:10095:80"
    volumes:
      - /xxxxxxxxxxxx/documents:/var/www/documents
      - /xxxxxxxxxxxx/custom:/var/www/html/custom

We use that and it is working good (we use an nginx reverse-proxy in front of dolibarr container to manage ssl).