Docker problems with MariaDB container

Let’s get a better overview: This is my docker-compose.yml

---
version: "3"

networks:
  invoiceplane:
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 172.25.0.0/17

volumes:
  invoiceplane-db:
    driver: "local"
  nginx_logs:
    driver: "local"

services:
  # --- PHP 8.1
  php:
    container_name: "invoiceplane-php"
    build:
      context: ./resources/docker/php-fpm
      args:
        - PUID=1000
        - PGID=1000
        - TZ=UTC
    links:
      - db
    expose:
      - "9000"
    dns: 8.8.8.8
    depends_on:
      - db
    networks:
      invoiceplane:
        ipv4_address: 172.25.0.11
    volumes:
      - .:/var/www/projects/invoiceplane:delegated
      - ./resources/docker/php-fpm/php-dev.ini:/usr/local/etc/php/php.ini

  # --- nginx 1.23
  nginx:
    container_name: "invoiceplane-nginx"
    build:
      context: ./resources/docker/nginx
    links:
      - php
    ports:
      - "8083:80"
    dns: 8.8.8.8
    depends_on:
      - php
    networks:
      invoiceplane:
        ipv4_address: 172.25.0.12
    volumes:
      - .:/var/www/projects/invoiceplane:delegated
      - nginx_logs:/var/log/nginx
      - ./resources/docker/nginx/invoiceplane.conf:/etc/nginx/conf.d/invoiceplane.conf:ro

  # --- MariaDB 10.9
  db:
    container_name: "invoiceplane-db"
    build:
      context: ./resources/docker/mariadb
    environment:
      - MARIADB_ROOT_PASSWORD=ipdevdb
      - MARIADB_USER=ipdevdb
      - MARIADB_PASSWORD=ipdevdb
      - MARIADB_DATABASE=invoiceplane_db
    ports:
      - "3306:3306"
    networks:
      invoiceplane:
        ipv4_address: 172.25.0.13
    volumes:
      - "invoiceplane-db:/var/lib/mysql"

  phpmyadmin:
    container_name: "invoiceplane-dbadmin"
    build:
      context: ./resources/docker/phpmyadmin
    environment:
      - PMA_HOST=invoiceplane-db
      #- PMA_USER=root
      #- PMA_PASSWORD=ipdevdb
      #- PMA_ROOT_PASSWORD=ipdevdb
      - MYSQL_DATABASE=invoiceplane_db
      - MYSQL_USER=ipdevdb
      - MYSQL_PASSWORD=ipdevdb
      - MYSQL_ROOT_PASSWORD=ipdevdb
      - MAX_EXECUTION_TIME=600
      - MEMORY_LIMIT=256M
      - UPLOAD_LIMIT=2G
    depends_on:
      - db
    links:
      - db
    restart: always
    volumes:
      - ./resources/docker/phpmyadmin/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php
      - ./resources/docker/databases:/var/www/html/tmp/upload_databases
    ports:
      - "8086:80"
    networks:
      invoiceplane:
        ipv4_address: 172.25.0.16

As you can see i needed to change some ports, for example the nginx is running on host port 8083, so i should get to the web overlay with hostname:8083.Open this in my browser redirects me to http://172.25.0.12/index.php/welcome which of course doesn’t exist and gives me a connection timeout error.

Edit: If i edit the ipconfig.php like this IP_URL=http://hostname the redirection truly works as it redirects to https://hostname/index.php/welcome - even if https is wrong (local usage, no need for ssl) and i still get connection error.

But hostname:8086 is opening the phpmyadmin overlay as expected (thus i can’t login there with ipdevdb:ipdevdb mysqli::real_connect(): (HY000/2002): No such file or directory). I think this is because my database (mariadb) is not running (exited) with this error:

2023-07-02 09:18:25+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:11.0.2+maria~ubu2204 started.
2023-07-02 09:18:25+00:00 [ERROR] [Entrypoint]: mariadbd failed while attempting to check config
        command was: mysqld --verbose --help
        /usr/local/bin/docker-entrypoint.sh: line 105: mysqld: command not found

So all in all there is this Entrypoint error related to the mariadb and this redirection to a ipadress which doesn’t exists. The main issue should be mysqld --verbose --help because mysqld doesn’t exist as a command (even if its defined and also like that on my fs?).

I don’t know if this is related but the docker-compose.yml is talking about MariaDB 10.9 even though it is using the latest version which is 11.0.2 with the latest tag.

@fnu You need to start it in a different way. I’ll let you know once I’ve brought up all those containers
just stop your mariadb container for now:
docker ps
docker-compose stop (id of the MariaDB container)

@fnu I can reproduce your problem with the MariaDB container.

The best things you can do is:
open resources/docker/mariadb/Dockerfile
Change FROM mariadb:latest to FROM mariadb:10.9 (any equivalent of version 10 will do most likely. The problem is with latest)
docker-compose up --build db -d. It will rebuild your mariadb db container

So… bring your containers down, you need to change another thing.

open resources/docker/phpmyadmin/config.user.inc.php
Change $cfg['Servers'][$i]['host'] = 'localhost'; to $cfg['Servers'][$i]['host'] = 'invoiceplane-db';

The thing I did extra was add the IP addresses of my docker containers to my /etc/hosts:

172.25.0.12 invoiceplane-nginx
172.25.0.11 invoiceplane-php
172.25.0.16 invoiceplane-dbadmin
172.25.0.13 invoiceplane-db
1 Like

Looks good, the db container is running right now, mariadb:10.9 did the trick. Maybe edit the docker-compose.yml at GitHub?

btw there is a small mistake (for any other user who reads this and have the same problem), the correct command is:
docker-compose up -d --build db

Edit: Also editing the config.user.inc.php like you explained is working like a charm. I can now access the database with phpmyadmin.

2 Likes