This problem is annoying me very much, it might be something stupidly simple to a good system admin but i've wasted many hours without success, i've tried many answer from SO and other websites and nothing works for me... I will be as detailed as I can
my system:
debian 11
docker-compose 1.25
Docker version 20.10.5+dfsg1, build 55c4c88
I'm trying to create a mariadb container using docker-compose. here is my yml file:
version: '3.3'
services:
dev-mariadb:
restart: always
container_name: dev-mariadb
image: 'mariadb:10.2.43'
command: --max_allowed_packet=32505856 --log_error=/var/log/mariadb.err --log_warnings=9
environment:
- TZ=America/Sao_Paulo
- LANG=C.UTF-8
- LC_ALL=C.UTF-8
- MARIADB_ROOT_PASSWORD=somepassword
volumes:
#- './dev-mariadb/etc:/etc'
#- "./dev-mariadb/etc/alternatives/my.cnf:/etc/alternatives/my.cnf"
- ./dev-mariadb/etc/mysql:/etc/mysql
- ./dev-mariadb/var/log/mysql:/var/log/mysql
- ./dev-mariadb/var/lib/mysql:/var/lib/mysql
- ./dev-mariadb/opt/dumps:/opt/dumps
ports:
- '43306:3306'
ulimits:
nproc: 99999
nofile:
soft: 99999
hard: 99999
networks:
- dev-databases
networks:
nginx:
external: true
dev-databases:
external: true
after i run docker-compose up -d
the necessary stuff is downloaded, the folders are created [if not exist] and the container starts.
the folders ./dev-mariadb/etc/mysql
and ./dev-mariadb/var/log/mysql
are completely empty
these folders are owned by root:root
and have 644
permission
As i said mariadb is running fine, i can login into it an execute queries normal. but when i try to add a my.cnf
to the ./dev-mariadb/etc/mysql
folder all my hell starts
this is my my.cnf file:
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
skip-character-set-client-handshake
default-storage-engine = InnoDB
character-set-server = utf8
transaction-isolation = READ-COMMITTED
max_connections=200
key_buffer = 16M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 16
myisam-recover = BACKUP
max_connections = 300
table_open_cache = 64
table_open_cache = 32
thread_concurrency = 4
I copy it to the host ./dev-mariadb/etc/mysql
, if i run docker exec -it dev-mariadb bash
and navigate to /etc/mysql i can see the file in there...
THERE IS NO OTHER FILES IN THAT FOLDER
i restart the container with docker-compose restart
BUT MARIADB WONT LOAD THE VARIABLES
i run docker-compose up -d
then mysql -u root -p
then show variables
all variables shows up and the max_connections
is 151 [the default value] while in my cnf file it is 300
i've tested changing many other variables and no changes take effect
if i run docker logs dev-mariadb
2022-06-18 11:55:51-03:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.2.43+maria~bionic started.
2022-06-18 11:55:51-03:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-06-18 11:55:51-03:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.2.43+maria~bionic started.
2022-06-18 11:55:51-03:00 [Note] [Entrypoint]: MariaDB upgrade not required
2022-06-18 11:55:51 139892145759936 [Note] mysqld (mysqld 10.2.43-MariaDB-1:10.2.43+maria~bionic) starting as process 1 ...
2022-06-18 11:55:51 139892145759936 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2022-06-18 11:55:51 139892145759936 [Note] InnoDB: Uses event mutexes
2022-06-18 11:55:51 139892145759936 [Note] InnoDB: Compressed tables use zlib 1.2.11
2022-06-18 11:55:51 139892145759936 [Note] InnoDB: Using Linux native AIO
2022-06-18 11:55:51 139892145759936 [Note] InnoDB: Number of pools: 1
2022-06-18 11:55:51 139892145759936 [Note] InnoDB: Using SSE2 crc32 instructions
2022-06-18 11:55:51 139892145759936 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2022-06-18 11:55:51 139892145759936 [Note] InnoDB: Completed initialization of buffer pool
2022-06-18 11:55:51 139891615004416 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2022-06-18 11:55:51 139892145759936 [Note] InnoDB: Highest supported file format is Barracuda.
2022-06-18 11:55:51 139892145759936 [Note] InnoDB: 128 out of 128 rollback segments are active.
2022-06-18 11:55:51 139892145759936 [Note] InnoDB: Creating shared tablespace for temporary tables
2022-06-18 11:55:51 139892145759936 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2022-06-18 11:55:51 139892145759936 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2022-06-18 11:55:51 139892145759936 [Note] InnoDB: 5.7.37 started; log sequence number 1615573
2022-06-18 11:55:51 139891178469120 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2022-06-18 11:55:51 139891178469120 [Note] InnoDB: Buffer pool(s) load completed at 220618 11:55:51
2022-06-18 11:55:51 139892145759936 [Note] Plugin 'FEEDBACK' is disabled.
2022-06-18 11:55:51 139892145759936 [Note] Server socket created on IP: '::'.
2022-06-18 11:55:51 139892145759936 [Note] Reading of all Master_info entries succeeded
2022-06-18 11:55:51 139892145759936 [Note] Added new Master_info '' to hash table
2022-06-18 11:55:51 139892145759936 [Note] mysqld: ready for connections.
Version: '10.2.43-MariaDB-1:10.2.43+maria~bionic' socket: '/var/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution
this is the result, nothing that i notice as clearly wrong appears.
WHAT I'VE TRIED:
1- I placed some gibberish in the my.cnf file... added a line with gibberish=123, restart the container then docker logs dev-mariadb and i get the result
2022-06-18 12:05:20-03:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check config
command was: mysqld --verbose --help --log-bin-index=/tmp/tmp.eFejrmnW1V
2022-06-18 12:05:20 140402577430208 [Note] Using unique option prefix 'key_buffer' is error-prone and can break in the future. Please use the full name 'key_buffer_size' instead.
2022-06-18 12:05:20 140402577430208 [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release.
2022-06-18 12:05:20 140402577430208 [Note] Using unique option prefix 'myisam-recover' is error-prone and can break in the future. Please use the full name 'myisam-recover-options' instead.
2022-06-18 12:05:20 140402577430208 [Note] Plugin 'FEEDBACK' is disabled.
2022-06-18 12:05:20 140402577430208 [ERROR] mysqld: unknown variable 'giberrish=123'
2022-06-18 12:05:20 140402577430208 [ERROR] Aborting
2022-06-18 12:05:21-03:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.2.43+maria~bionic started.
2022-06-18 12:05:21-03:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check config
command was: mysqld --verbose --help --log-bin-index=/tmp/tmp.Keq0VKkU6F
2022-06-18 12:05:21 140636118210240 [Note] Using unique option prefix 'key_buffer' is error-prone and can break in the future. Please use the full name 'key_buffer_size' instead.
2022-06-18 12:05:21 140636118210240 [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release.
2022-06-18 12:05:21 140636118210240 [Note] Using unique option prefix 'myisam-recover' is error-prone and can break in the future. Please use the full name 'myisam-recover-options' instead.
2022-06-18 12:05:21 140636118210240 [Note] Plugin 'FEEDBACK' is disabled.
2022-06-18 12:05:21 140636118210240 [ERROR] mysqld: unknown variable 'giberrish=123'
2022-06-18 12:05:21 140636118210240 [ERROR] Aborting
it means the mariadb is READING THE FILE
2- i've added the line
command: --max_allowed_packet=32505856 --log_error=/var/log/mariadb.err --log_warnings=9 --max-connections=500
in the docker-compose file, then restarted then log and show variables; THEN THE MAX_CONNECTIONS IS 500
I'm using the MAX_CONNECTIONS variable as example but i've tested with many other variables and they also behave the same
I dont want to set lots of fine grained optimization variables in the docker-compose file.... i want to have it in a separate file the way it is meant to be
what am i doing wrong, can anyone please help me?