[MDEV-29288] MariaDB Docker container on Created: 2022-08-10  Updated: 2022-08-11  Resolved: 2022-08-11

Status: Closed
Project: MariaDB Server
Component/s: N/A
Affects Version/s: None
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Maduranga Assignee: Daniel Black
Resolution: Not a Bug Votes: 0
Labels: Compatibility, docker
Environment:

Docker container using compose



 Description   

Hi,

I found a few issues related to this but couldn't nail anything down close to the exact matter describing below, hence creating a new ticket.

This is about the MariaDB changing the permissions on the bind mount to a level such that it becomes read-only, then fails to write to the directory, resulting a failure.

First block below is the error from the docker logs. Second is the compose file I used to build the docker containers.

 
2022-08-10 20:25:51+00:00 [Note] [Entrypoint]: Initializing database files
2022-08-10 20:25:51 0 [Warning] Can't create test file /var/lib/mysql/da60fb480af6.lower-test
/usr/sbin/mariadbd: Can't change dir to '/var/lib/mysql/' (Errcode: 13 "Permission denied")
2022-08-10 20:25:51 0 [ERROR] Aborting
 
Installation of system tables failed!  Examine the logs in
/var/lib/mysql/ for more information.
 
The problem could be conflicting information in an external
my.cnf files. You can ignore these by doing:
 
    shell> /usr/bin/mariadb-install-db --defaults-file=~/.my.cnf
 
You can also try to start the mysqld daemon with:
 
    shell> /usr/sbin/mariadbd --skip-grant-tables --general-log &
 
and use the command line tool /usr/bin/mariadb
to connect to the mysql database and look at the grant tables:
 
    shell> /usr/bin/mysql -u root mysql
    mysql> show tables;
 
Try 'mysqld --help' if you have problems with paths.  Using
--general-log gives you a log in /var/lib/mysql/ that may be helpful.
 
The latest information about mysql_install_db is available at
https://mariadb.com/kb/en/installing-system-tables-mysql_install_db
You can find the latest source at https://downloads.mariadb.org and
the maria-discuss email list at https://launchpad.net/~maria-discuss
 
Please check all of the above before submitting a bug report
at https://mariadb.org/jira
 
2022-08-10 20:25:59+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.8.3+maria~jammy started.}}

Compose file:

services:
  db:
    # We use a mariadb image which supports both amd64 & arm64 architecture
    # image: mariadb:10.6.4-focal
    image: mariadb
    # If you really want to use MySQL, uncomment the following line
    #image: mysql:8.0.27
    command: '--default-authentication-plugin=mysql_native_password'
    volumes:
      - ./wp_db:/var/lib/mysql:rw
      # - type: bind
      #   source: ./wp_db
      #   target: /var/lib/mysql
      # # - ./wp_db:/var/lib/mysql:rw
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=somewordpress
      - MYSQL_DATABASE=wordpress
      - MYSQL_USER=wordpress
      - MYSQL_PASSWORD=wordpress
    expose:
      - 3306
      - 33060
  wordpress:
    image: wordpress:latest
    ports:
      - 8008:80
    restart: always
    volumes:
      - ./wp_site:/var/www/html
    environment:
      - WORDPRESS_DB_HOST=db
      - WORDPRESS_DB_USER=wordpress
      - WORDPRESS_DB_PASSWORD=wordpress
      - WORDPRESS_DB_NAME=wordpress

Server OS information

$ uname -a
Linux SynologyDS 4.4.180+ #42661 SMP Mon Jun 27 15:07:23 CST 2022 x86_64 GNU/Linux synology_broadwellnk_1621xs+

Notes

There are two containers created by the compose file. First is the MariaDB and second is the Apache HTTPD.
Both does the same thing, just bind a read-write (./wp_site:/var/www/html) from the host to the container. Apache HTTPD writes without an issue MariaDB fails (I tried ./wp_db:/var/lib/mysql, ./wp_db:/var/lib/mysql:rw without luck) with aforementioned error. For me, the issue happens only on the above Linux OS, not producible on MacOS.



 Comments   
Comment by Daniel Black [ 2022-08-11 ]

What is the full permissions on ./wp_db (ls -laZ ./wp_db?

What docker/container runtime version is being used?

Is SynologyDS based closely on another Linux distro?

Comment by Maduranga [ 2022-08-11 ]

Full permissions are as follows:

$ ls -laZ ./wp_db
total 0
drw-rw----  1  999 synopkgs ?   0 Aug 11 11:29 .
d---------+ 1 root root     ? 140 Aug 11 06:24 ..
 
$ ls -l ./wp_db
drw-rw----  1  999 synopkgs   0 Aug 11 11:29 wp_db
 
$ ls -l ./dir_before_container_run
drwxrwxrwx  1 root root       0 Aug 12 06:22 dir_before_container_run

Despite what permissions I give to the folder that seem to change after a single run of the container.

$ docker --version
Docker version 20.10.3, build 55f0773

Synology DSM Seem to say its a GNU/Linux. I suspect it could be a Debian distro, I don't have evidence on that.
However following from uname --all command

Linux SynologyDS 4.4.180+ #42661 SMP Mon Jun 27 15:07:23 CST 2022 x86_64 GNU/Linux

Comment by Daniel Black [ 2022-08-11 ]

Something is removing the exec permissions on the mount point which makes it rather broken. Maybe its how its mounted.

option:

  • Could try to give them back chmod a+x wp_db and that might work.
  • given 999 is the user id of mysql in the container, run the container with user: mysql
  • create a container named volume wp_db and use that as the storage.

The container doesn't remove exec permissions so sorry to say its something in your environment causing this. I hope one of the options provides a work around.

Generated at Thu Feb 08 10:07:22 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.