How to enable MariaDB 4-byte support in docker

In the manual it is missing the information for how to do this if you are using docker images: https://docs.nextcloud.com/server/stable/admin_manual/configuration_database/mysql_4byte_support.html

you create a nextcloud-mysql.cnf file on your host and map it via volume into the container.

similar to: Cannot Hook Into PHP Folder via Docker

you can find this also in the mariadb readme on docker hub: https://hub.docker.com/_/mariadb

Using a custom MySQL configuration file

The startup configuration is specified in the file /etc/mysql/my.cnf, and that file in turn includes any files found in the /etc/mysql/conf.d directory that end with .cnf. Settings in files in this directory will augment and/or override settings in /etc/mysql/my.cnf. If you want to use a customized MySQL configuration, you can create your alternative configuration file in a directory on the host machine and then mount that directory location as /etc/mysql/conf.d inside the mariadb container.

If /my/custom/config-file.cnf is the path and name of your custom configuration file, you can start your mariadb container like this (note that only the directory path of the custom config file is used in this command):

$ docker run --name some-mariadb -v /my/custom:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mariadb:tag

This will start a new container some-mariadb where the MariaDB instance uses the combined startup settings from /etc/mysql/my.cnf and /etc/mysql/conf.d/config-file.cnf, with settings from the latter taking precedence.

You can run a bash shell on the container and follow the same procedure, I think. I did this on mine but was some time ago.

wouldn’t that be vanish again, if you update the container?

Only if you throw the baby out with the bath water…

“to lose valuable ideas or things in your attempt to get rid of what is not wanted”???

I thought, sometimes, you recreate the container, because all data that are specific should be mounted via volumes, to survive such a re-creation of the container?

If you use a Docker container database, you need a permanent volume mount so your database is persistent. Then you delete and recreate the container, and all the software in the image is updated, but the database remains.

maybe you can clarify how? which script? in which volume will it fix the 4-byte issue?

To open a shell on a container:

docker exec -it container /bin/bash

Then you can get into MySQL locally. As for the volume, you need either a named volume or host folder mounted where the database is so the data can be re-attached when you cycle the container.

All of that is covered in detail here.
https://hub.docker.com/_/mariadb

I’m more of a docker-compose user but you can just use

You can see what a config should look like at Nextcloud Database Configuration. Although your config could vary depending on your usecase.
You should look into the examples from the nextcloud docker repo if you want to get into using docker-compose files.

If you want to go docker-compose, this is how it should look like (could be slimmed down if you want to, look at examples from the repo and take what you need from this)
version: '3'

volumes:
  nextcloud:
  nextcloud_data: #persistent
    external: true
  nextcloud_config: #persistent
    external: true
  nextcloud_db: #persistent
    external: true
  nextcloud_apps: #persistent
    external: true
  

services:
  db:
    container_name: nextcloud_db
    image: mariadb #jsurf/rpi-mariadb
    restart: always
    volumes:
      - nextcloud_db:/var/lib/mysql
      - /my/path/to/myconfig.cnf:/etc/mysql/conf.d/myconfig.cnf:ro #your mysql config
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
      - MYSQL_DATABASE=${MYSQL_DATABASE}
      - MYSQL_USER=${MYSQL_USER}

  app:
    container_name: nextcloud
    image: nextcloud:apache
    ports:
      - ${NEXTCLOUD_HTTP_PORT}:80
    links:
      - db
    volumes:
      - nextcloud:/var/www/html
      - nextcloud_data:/var/www/html/data
      - nextcloud_config:/var/www/html/config
      - nextcloud_apps:/var/www/html/custom_apps
      #- /my/path/to/my.config.php:/var/www/html/config/my.config.php
    environment:
     - NEXTCLOUD_ADMIN_USER=${NEXTCLOUD_ADMIN}
     - NEXTCLOUD_ADMIN_PASSWORD=${NEXTCLOUD_ADMINPW}
     - MYSQL_DATABASE=${MYSQL_DATABASE}
     - MYSQL_USER=${MYSQL_USER}
     - MYSQL_PASSWORD=${MYSQL_PASSWORD}
     - MY_SQL_HOST=db
    restart: always

my mysql config looks currently like this (not the missing includes from the example at the first link, they would create an infinite inclusion loop):

[server]
skip-name-resolve
innodb_buffer_pool_size = 128M
innodb_buffer_pool_instances = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 32M
innodb_max_dirty_pages_pct = 90
query_cache_type = 1
query_cache_limit = 2M
query_cache_min_res_unit = 2k
query_cache_size = 32M
tmp_table_size= 64M
max_heap_table_size= 64M
slow-query-log = 1
slow-query-log-file = /var/log/mysql/slow.log
long_query_time = 1

join_buffer_size = 256k

key_buffer = 64M

[client]
default-character-set = utf8mb4

[mysqld]
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
transaction_isolation = READ-COMMITTED
binlog_format = ROW
innodb_large_prefix=on
innodb_file_format=barracuda
innodb_file_per_table=1
default_authentication_plugin=mysql_native_password