couldn't run docker when mount volume - docker

I am new to docker and I tried to run a mariadb daemon in docker.
I could run mariadb as a daemon with the command
PS D:\docker> docker run --name mariadb2 -e MYSQL_ROOT_PASSWORD=password -d mariadb
but couldn't run with the command
PS D:\docker> docker run --name mariadb2 -v /d/docker/volume/db:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=password -d mariadb
the folder had some files created in there so it should have mounted properly.
Here is the log and system info
> PS D:\docker> docker logs mariadb2
Initializing database
2016-08-15 8:50:13 139894536869824 [Note] /usr/sbin/mysqld (mysqld 10.1.16-MariaDB-1~jessie) starting as process 51 ...
2016-08-15 8:50:13 139894536869824 [Note] InnoDB: Using mutexes to ref count buffer pool pages
2016-08-15 8:50:13 139894536869824 [Note] InnoDB: The InnoDB memory heap is disabled
2016-08-15 8:50:13 139894536869824 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-08-15 8:50:13 139894536869824 [Note] InnoDB: Memory barrier is not used
2016-08-15 8:50:13 139894536869824 [Note] InnoDB: Compressed tables use zlib 1.2.8
2016-08-15 8:50:13 139894536869824 [Note] InnoDB: Using Linux native AIO
2016-08-15 8:50:13 139894536869824 [Note] InnoDB: Using SSE crc32 instructions
2016-08-15 8:50:13 139894536869824 [Note] InnoDB: Initializing buffer pool, size = 256.0M
2016-08-15 8:50:13 139894536869824 [Note] InnoDB: Completed initialization of buffer pool
2016-08-15 8:50:13 139894536869824 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2016-08-15 8:50:13 139894536869824 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2016-08-15 8:50:13 139894536869824 [Note] InnoDB: Database physically writes the file full: wait...
2016-08-15 08:50:13 7f3bbc2d17c0 InnoDB: Error: Write to file ./ibdata1 failed at offset 0.
InnoDB: 1048576 bytes should have been written, only 0 were written.
InnoDB: Operating system error number 22.
InnoDB: Check that your OS and file system support files of this size.
InnoDB: Check also that the disk is not full or a disk quota exceeded.
InnoDB: Error number 22 means 'Invalid argument'.
InnoDB: Some operating system error numbers are described at
InnoDB: http://dev.mysql.com/doc/refman/5.6/en/operating-system-error-codes.html
2016-08-15 8:50:13 139894536869824 [ERROR] InnoDB: Error in creating ./ibdata1: probably out of disk space
2016-08-15 8:50:13 139894536869824 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to
ailed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in th
rote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your prec
2016-08-15 8:50:13 139894536869824 [ERROR] Plugin 'InnoDB' init function returned error.
2016-08-15 8:50:13 139894536869824 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2016-08-15 8:50:14 139894536869824 [ERROR] Unknown/unsupported storage engine: InnoDB
2016-08-15 8:50:14 139894536869824 [ERROR] Aborting
PS D:\docker> docker info
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 27
Server Version: 1.12.0
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 77
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: host bridge null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: seccomp
Kernel Version: 4.4.15-moby
Operating System: Alpine Linux v3.4
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.95 GiB
Name: moby
ID: ZCNG:T3MP:ORJH:E5V4:SBTR:PFKC:DMBM:IG2C:QHQE:FICI:ALHP:JKNO
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
127.0.0.0/8
PS D:\docker> docker version
Client:
Version: 1.12.0
API version: 1.24
Go version: go1.6.3
Git commit: 8eab29e
Built: Thu Jul 28 21:04:48 2016
OS/Arch: windows/amd64
Experimental: true
Server:
Version: 1.12.0
API version: 1.24
Go version: go1.6.3
Git commit: 8eab29e
Built: Thu Jul 28 21:04:48 2016
OS/Arch: linux/amd64
Experimental: true
Thanks in advance

I had the same issue before.
Apparently when using docker on windows (in my case) it had problems with the file path. The solution in that case was to create a volume in docker by using the following command:
docker volume create --name=your_volume
then in docker compose you would have something like
db:
image: mariadb
volumes:
- volume_db:/var/lib/mysql
Hopes this helps you

Related

Why does MariaDB on Docker runs much slower than 'native' MariaDB package on the same Synology machine?

There is a Synology DS1621xs+ (equiped with NVMe SSD cache and 24 GB RAM).
OS: Synology DSM 7.1
File System: btrfs
Docker version: 20.10.3
There is a MariaDB10 server running on Docker on this machine.
An identical database is running on the 'native' Synology MariaDB10 package on the same machine. (Dumped and copied from the Docker instance.)
Queries on the database of the 'native' MariaDB10 package run much faster than on the docker instance. Difference is at least 2.5x, but on some queries it is 20x.
What might be the reason of this huge perfomance difference, why are the queries slower on Docker than on the Synology Package version of MariaDB?
Dockerinfo:
Client:
Context: default
Debug Mode: false
Server:
Containers: 10
Running: 7
Paused: 0
Stopped: 3
Images: 36
Server Version: 20.10.3
Storage Driver: btrfs
Build Version: Btrfs v4.0
Library Version: 101
Logging Driver: db
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs db fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 3fa00912415f3e9c6f82dd72119179d599efd13b
runc version: 31cc25f16f5eba4d0f53e35374532873744f4b31
init version: ed96d00 (expected: de40ad0)
Security Options:
apparmor
Kernel Version: 4.4.180+
Operating System: (containerized)
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 23.25GiB
Name: NAS
ID: ZLGI:KUWA:HOGC:3J6W:B6NJ:CZLJ:ZQP2:HAG5:3DP6:OEPX:5WRW:IHAJ
Docker Root Dir: /volume2/#docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No kernel memory TCP limit support
WARNING: No cpu cfs quota support
WARNING: No cpu cfs period support
WARNING: No blkio weight support
WARNING: No blkio weight_device support
WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support
`
MariaDB container log:
2022-11-19T08:55:19.209130033Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: Buffer pool(s) load completed at 221119 9:55:19
2022-11-19T08:55:19.174115217Z stdout Version: '10.6.5-MariaDB-1:10.6.5+maria~focal' socket: '/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution
2022-11-19T08:55:19.174011946Z stdout 2022-11-19 9:55:19 0 [Note] mysqld: ready for connections.
2022-11-19T08:55:19.167072919Z stdout 2022-11-19 9:55:19 0 [Warning] 'proxies_priv' entry '#% root#mariadb-copy' ignored in --skip-name-resolve mode.
2022-11-19T08:55:19.163349561Z stdout 2022-11-19 9:55:19 0 [Note] Server socket created on IP: '::'.
2022-11-19T08:55:19.163211778Z stdout 2022-11-19 9:55:19 0 [Note] Server socket created on IP: '0.0.0.0'.
2022-11-19T08:55:19.161820288Z stdout 2022-11-19 9:55:19 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
2022-11-19T08:55:19.149901116Z stdout 2022-11-19 9:55:19 0 [Note] Plugin 'FEEDBACK' is disabled.
2022-11-19T08:55:19.149840357Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2022-11-19T08:55:19.149391807Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: 10.6.5 started; log sequence number 3282096825; transaction id 7204
2022-11-19T08:55:19.148296829Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2022-11-19T08:55:19.148223400Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2022-11-19T08:55:19.148147151Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2022-11-19T08:55:19.147243337Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: 128 rollback segments are active.
2022-11-19T08:55:19.086673922Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: Completed initialization of buffer pool
2022-11-19T08:55:19.085986215Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
2022-11-19T08:55:19.085469623Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: Using Linux native AIO
2022-11-19T08:55:19.068551244Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2022-11-19T08:55:19.068528556Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: Number of pools: 1
2022-11-19T08:55:19.068487467Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: Using transactional memory
2022-11-19T08:55:19.068374374Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2022-11-19T08:55:19.049836283Z stdout 2022-11-19 9:55:19 0 [Note] mysqld (server 10.6.5-MariaDB-1:10.6.5+maria~focal) starting as process 1 ...
2022-11-19T08:55:18.900158637Z stdout 2022-11-19 09:55:18+01:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.3.14+maria~bionic started.
2022-11-19T08:55:18.892594609Z stdout 2022-11-19 09:55:18+01:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-11-19T08:55:18.738312960Z stdout 2022-11-19 09:55:18+01:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.3.14+maria~bionic started.
MariaDB changed innodb_flush_method=O_DIRECT in 10.6 to aid the high end performance. As such MariaDB-10.6 is much more reliant on a innodb_buffer_pool_size and innodb_log_file_size to gain read/write performance.
As a work around, test 10.6 with innodb_flush_method=fsync. btrfs is significantly newer than today than in kernel 4.4.0 so maybe its O_DIRECT paths weren't as performing in 4.4.0.
It could also be MDEV-29967 broken linear read ahead that we're working hard to fix before the next release.
It might also be the 10.6 statistics are different try a recalculation using ANALYZE TABLES.
There's a couple of btrfs links/suggestions in this link.
Or it could be something totally different requiring:
careful measurement and breakdown of individual queries and their execution.
elimination of local environment (running a 10.3 version in the container of the same version/configuration as the local package).

Mounting mariadb backup to docker container

I took mariadb backup of my mariadb server using below command:
mariabackup --backup --target-dir=/root/mariabackup --databases='MYDATABASE' -- tables='Table7' --user=root
ls /root/mariabackup
MYDATABASE backup-my.cnf ibdata1
aria_log.00000001 ib_buffer_pool xtrabackup_checkpoints
aria_log_control ib_logfile0 xtrabackup_info
I run my container and mount above directory with /var/lib/mysql using below command:
docker run --name=BackupCont -e MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=Y -p 3309:3309 --mount type=bind,src=/root/mariabackup,dst=/var/lib/mysql -d mariadb
I run docker logs BackupCont and it shows below:
2022-05-30 07:59:18+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.8.3+maria~jammy started.
2022-05-30 07:59:18+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-05-30 07:59:18+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.8.3+maria~jammy started.
2022-05-30 07:59:18+00:00 [Note] [Entrypoint]: Initializing database files
2022-05-30 7:59:18 0 [Warning] mariadbd: io_uring_queue_init() failed with ENOMEM: try larger memory locked limit, ulimit -l, or https://mariadb.com/kb/en/systemd/#configuring-limitmemlock under systemd (262144 bytes required)
2022-05-30 7:59:18 0 [Warning] InnoDB: liburing disabled: falling back to innodb_use_native_aio=OFF
2022-05-30 7:59:18 0 [ERROR] InnoDB: File ./ib_logfile0 is too small
2022-05-30 7:59:18 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2022-05-30 7:59:18 0 [ERROR] Plugin 'InnoDB' init function returned error.
2022-05-30 7:59:18 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2022-05-30 7:59:18 0 [ERROR] Unknown/unsupported storage engine: InnoDB
2022-05-30 7:59:18 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
You can see after running the container when I run docker logs BackupCont, this is the error I am getting while mounting. The backup directory have backup of mariadb version 10.3.34

mariadb (in docker) corruption. Fix or reset database?

I am using the official mariadb docker image, and after updating to latest version (10.5.8), I started getting errors about corruption (see logs below). Since this persists when I downgrade to earlier mariadb versions, I guess it's a database corruption?
Is there a way to fix it? and if not, how do I just reset the database (it's not the end of the world to lose data in database, but it is if the mariadb container does not start to work).
logs (this repeats):
2020-11-18 15:45:35+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.8+maria~focal started.
2020-11-18 15:45:35+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2020-11-18 15:45:35+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.8+maria~focal started.
2020-11-18 15:45:36 0 [Note] mysqld (mysqld 10.5.8-MariaDB-1:10.5.8+maria~focal) starting as process 1 ...
2020-11-18 15:45:36 0 [Note] InnoDB: Using Linux native AIO
2020-11-18 15:45:36 0 [Note] InnoDB: Uses event mutexes
2020-11-18 15:45:36 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-11-18 15:45:36 0 [Note] InnoDB: Number of pools: 1
2020-11-18 15:45:36 0 [Note] InnoDB: Using SSE4.2 crc32 instructions
2020-11-18 15:45:36 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
2020-11-18 15:45:36 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
2020-11-18 15:45:36 0 [Note] InnoDB: Completed initialization of buffer pool
2020-11-18 15:45:36 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-11-18 15:45:36 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=20174219501,20174219501
2020-11-18 15:45:36 0 [Note] InnoDB: Starting final batch to recover 3205 pages from redo log.
2020-11-18 15:45:36 0 [ERROR] InnoDB: Not applying INSERT_REUSE_REDUNDANT due to corruption on [page id: space=0, page number=2062]
2020-11-18 15:45:36 0 [ERROR] InnoDB: Set innodb_force_recovery=1 to ignore corruption.
2020-11-18 15:45:36 0 [ERROR] InnoDB: Not applying INSERT_REUSE_REDUNDANT due to corruption on [page id: space=0, page number=2062]
2020-11-18 15:45:36 0 [ERROR] InnoDB: Set innodb_force_recovery=1 to ignore corruption.
2020-11-18 15:45:36 0 [ERROR] InnoDB: Not applying INSERT_REUSE_REDUNDANT due to corruption on [page id: space=0, page number=2062]
2020-11-18 15:45:36 0 [ERROR] InnoDB: Set innodb_force_recovery=1 to ignore corruption.
2020-11-18 15:45:36 0 [ERROR] InnoDB: Not applying INSERT_REUSE_REDUNDANT due to corruption on [page id: space=0, page number=2062]
2020-11-18 15:45:36 0 [ERROR] InnoDB: Set innodb_force_recovery=1 to ignore corruption.
2020-11-18 15:45:36 0 [ERROR] InnoDB: Plugin initialization aborted with error Data structure corruption
2020-11-18 15:45:36 0 [Note] InnoDB: Starting shutdown...
2020-11-18 15:45:37 0 [ERROR] Plugin 'InnoDB' init function returned error.
2020-11-18 15:45:37 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2020-11-18 15:45:37 0 [Note] Plugin 'FEEDBACK' is disabled.
2020-11-18 15:45:37 0 [ERROR] Unknown/unsupported storage engine: InnoDB
2020-11-18 15:45:37 0 [ERROR] Aborting
And using this docker-compose.yaml:
hass_db:
image: mariadb:latest
# image: mariadb:10.5.4
# image: mariadb:10.4.14
container_name: hass_db
environment:
MYSQL_ROOT_PASSWORD: Maria4sud0
MYSQL_DATABASE: homeassistant
MYSQL_USER: homeassistant
MYSQL_PASSWORD: Maria4HAss
restart: on-failure
volumes:
- /mnt/data/docker/hass_db:/var/lib/mysql
networks:
mynet:
ipv4_address: 172.11.0.7

docker-compose mariadb docker-entrypoint-initdb.d sql is not executed

I am attempting to have my docker db container automatically populate the database with a dataset when created. According to the mariadb documentation, there is an docker-entrypoint-initdb.d folder in the volume that can be used for this purpose.
I set up my docker-compose.yml file to mirror examples that I have found on StackOverflow, but am still unable to get my SQL scripts to execute. Here are the relevant pieces of my docker-compose.yml file:
version: '3.6'
services:
db:
image: mariadb:10.5.4-focal
container_name: db
volumes:
- ./cms/conf/mysql/data/:/var/lib/mysql/:rw
- ./cms/sql/:/docker-entrypoint-initdb.d/:ro
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_USER=root
- MYSQL_PASSWORD=password
- MYSQL_DATABASE=wordpress
restart: always
adminer:
image: adminer:4.7.7-standalone
container_name: adminer
links:
- db
ports:
- 8080:8080
restart: always
Next to the docker-compose.yml file, I have a cms/sql/init.sql file with the following contents:
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET utf8mb4 */;
USE `test`;
Prior to each test iteration, I clean up any old/cached Docker content:
$ docker-compose down -v I've found this doesn't actually remove the db volumes. Running a docker volume ls still shows past volumes present.
$ docker volume prune This clears out the volumes. Running docker volume ls after running this shows an empty list.
$ rm -rf ./cms/conf/mysql This cleans out any actual filesystem changes that the db container made.
$ docker-compose up -d --build To rebuild the containers. This should trigger my initialization SQL scripts.
Docker runs, and the db container gets successfully created. I am able to access the adminer container running on localhost:8080. I am able to log in as the root user with the password specified in the docker-compose.yml file.
The Adminer interface shows the standard MySQL databases (information_schema, mysql, performance_schema) and additionally shows the wordpress database defined in the MYSQL_DATABASE value of the docker-compose.yml file. But my test database from the init.sql is nowhere to be found.
I found some other similar StackOverflow questions that have had similar problems. I've followed the accepted answers, and am still unable to get any SQL scripts to get executed.
docker-compose.yml, postgress, how to setup db, tables and prepop in an init.sql file?
Issue with docker compose initial DB setup once
mySQL init scripts not running with docker-compose
Create database on docker-compose startup
Here's the Docker log from my db container. I didn't see anything that looked strange; no error messages about initialization, etc:
2020-07-15 19:21:34+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.4+maria~focal started.
2020-07-15 19:21:35+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2020-07-15 19:21:35+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.4+maria~focal started.
2020-07-15 19:21:35+00:00 [Note] [Entrypoint]: Initializing database files
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:
'/usr/bin/mysqladmin' -u root password 'new-password'
'/usr/bin/mysqladmin' -u root -h password 'new-password'
Alternatively you can run:
'/usr/bin/mysql_secure_installation'
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the MariaDB Knowledgebase at https://mariadb.com/kb or the
MySQL manual for more instructions.
Please report any problems at https://mariadb.org/jira
The latest information about MariaDB is available at https://mariadb.org/.
You can find additional information about the MySQL part at:
https://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/
2020-07-15 19:21:47+00:00 [Note] [Entrypoint]: Database files initialized
2020-07-15 19:21:47+00:00 [Note] [Entrypoint]: Starting temporary server
2020-07-15 19:21:47+00:00 [Note] [Entrypoint]: Waiting for server startup
2020-07-15 19:21:47 0 [Note] mysqld (mysqld 10.5.4-MariaDB-1:10.5.4+maria~focal) starting as process 107 ...
2020-07-15 19:21:47 0 [Note] InnoDB: Using Linux native AIO
2020-07-15 19:21:47 0 [Note] InnoDB: Uses event mutexes
2020-07-15 19:21:47 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-07-15 19:21:47 0 [Note] InnoDB: Number of pools: 1
2020-07-15 19:21:47 0 [Note] InnoDB: Using SSE4.2 crc32 instructions
2020-07-15 19:21:47 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
2020-07-15 19:21:47 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
2020-07-15 19:21:47 0 [Note] InnoDB: Completed initialization of buffer pool
2020-07-15 19:21:47 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-07-15 19:21:48 0 [Note] InnoDB: 128 rollback segments are active.
2020-07-15 19:21:48 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-07-15 19:21:48 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-07-15 19:21:49 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2020-07-15 19:21:49 0 [Note] InnoDB: 10.5.4 started; log sequence number 45041; transaction id 21
2020-07-15 19:21:49 0 [Note] Plugin 'FEEDBACK' is disabled.
2020-07-15 19:21:49 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2020-07-15 19:21:49 0 [Note] InnoDB: Buffer pool(s) load completed at 200715 19:21:49
2020-07-15 19:21:49 0 [Warning] 'user' entry 'root#5666e0d8e52e' ignored in --skip-name-resolve mode.
2020-07-15 19:21:49 0 [Warning] 'user' entry '#5666e0d8e52e' ignored in --skip-name-resolve mode.
2020-07-15 19:21:49 0 [Warning] 'proxies_priv' entry '#% root#5666e0d8e52e' ignored in --skip-name-resolve mode.
2020-07-15 19:21:49 0 [Note] Reading of all Master_info entries succeeded
2020-07-15 19:21:49 0 [Note] Added new Master_info '' to hash table
2020-07-15 19:21:49 0 [Note] mysqld: ready for connections.
Version: '10.5.4-MariaDB-1:10.5.4+maria~focal' socket: '/run/mysqld/mysqld.sock' port: 0 mariadb.org binary distribution
2020-07-15 19:21:49+00:00 [Note] [Entrypoint]: Temporary server started.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it.
2020-07-15 19:21:58 5 [Warning] 'proxies_priv' entry '#% root#5666e0d8e52e' ignored in --skip-name-resolve mode.
2020-07-15 19:21:58+00:00 [Note] [Entrypoint]: Creating database wordpress23
2020-07-15 19:21:58+00:00 [Note] [Entrypoint]: Creating user root
ERROR 1396 (HY000) at line 1: Operation CREATE USER failed for 'root'#'%'
2020-07-15 19:21:34+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.4+maria~focal started.
2020-07-15 19:21:35+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2020-07-15 19:21:35+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.4+maria~focal started.
2020-07-15 19:21:35+00:00 [Note] [Entrypoint]: Initializing database files
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:
'/usr/bin/mysqladmin' -u root password 'new-password'
'/usr/bin/mysqladmin' -u root -h password 'new-password'
Alternatively you can run:
'/usr/bin/mysql_secure_installation'
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the MariaDB Knowledgebase at https://mariadb.com/kb or the
MySQL manual for more instructions.
Please report any problems at https://mariadb.org/jira
The latest information about MariaDB is available at https://mariadb.org/.
You can find additional information about the MySQL part at:
https://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/
2020-07-15 19:21:47+00:00 [Note] [Entrypoint]: Database files initialized
2020-07-15 19:21:47+00:00 [Note] [Entrypoint]: Starting temporary server
2020-07-15 19:21:47+00:00 [Note] [Entrypoint]: Waiting for server startup
2020-07-15 19:21:47 0 [Note] mysqld (mysqld 10.5.4-MariaDB-1:10.5.4+maria~focal) starting as process 107 ...
2020-07-15 19:21:47 0 [Note] InnoDB: Using Linux native AIO
2020-07-15 19:21:47 0 [Note] InnoDB: Uses event mutexes
2020-07-15 19:21:47 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-07-15 19:21:47 0 [Note] InnoDB: Number of pools: 1
2020-07-15 19:21:47 0 [Note] InnoDB: Using SSE4.2 crc32 instructions
2020-07-15 19:21:47 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
2020-07-15 19:21:47 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
2020-07-15 19:21:47 0 [Note] InnoDB: Completed initialization of buffer pool
2020-07-15 19:21:47 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-07-15 19:21:48 0 [Note] InnoDB: 128 rollback segments are active.
2020-07-15 19:21:48 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-07-15 19:21:48 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-07-15 19:21:49 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2020-07-15 19:21:49 0 [Note] InnoDB: 10.5.4 started; log sequence number 45041; transaction id 21
2020-07-15 19:21:49 0 [Note] Plugin 'FEEDBACK' is disabled.
2020-07-15 19:21:49 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2020-07-15 19:21:49 0 [Note] InnoDB: Buffer pool(s) load completed at 200715 19:21:49
2020-07-15 19:21:49 0 [Warning] 'user' entry 'root#5666e0d8e52e' ignored in --skip-name-resolve mode.
2020-07-15 19:21:49 0 [Warning] 'user' entry '#5666e0d8e52e' ignored in --skip-name-resolve mode.
2020-07-15 19:21:49 0 [Warning] 'proxies_priv' entry '#% root#5666e0d8e52e' ignored in --skip-name-resolve mode.
2020-07-15 19:21:49 0 [Note] Reading of all Master_info entries succeeded
2020-07-15 19:21:49 0 [Note] Added new Master_info '' to hash table
2020-07-15 19:21:49 0 [Note] mysqld: ready for connections.
Version: '10.5.4-MariaDB-1:10.5.4+maria~focal' socket: '/run/mysqld/mysqld.sock' port: 0 mariadb.org binary distribution
2020-07-15 19:21:49+00:00 [Note] [Entrypoint]: Temporary server started.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it.
2020-07-15 19:21:58 5 [Warning] 'proxies_priv' entry '#% root#5666e0d8e52e' ignored in --skip-name-resolve mode.
2020-07-15 19:21:58+00:00 [Note] [Entrypoint]: Creating database wordpress
2020-07-15 19:21:58+00:00 [Note] [Entrypoint]: Creating user root
ERROR 1396 (HY000) at line 1: Operation CREATE USER failed for 'root'#'%'
2020-07-15 19:21:59+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.4+maria~focal started.
2020-07-15 19:22:00+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2020-07-15 19:22:00+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.4+maria~focal started.
2020-07-15 19:22:01 0 [Note] mysqld (mysqld 10.5.4-MariaDB-1:10.5.4+maria~focal) starting as process 1 ...
2020-07-15 19:22:01 0 [Note] mysqld: Aria engine: starting recovery
recovered pages: 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% (0.3 seconds); tables to flush: 4 3 2 1 0
(0.0 seconds);
2020-07-15 19:22:01 0 [Note] mysqld: Aria engine: recovery done
2020-07-15 19:22:01 0 [Note] InnoDB: Using Linux native AIO
2020-07-15 19:22:01 0 [Note] InnoDB: Uses event mutexes
2020-07-15 19:22:01 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-07-15 19:22:01 0 [Note] InnoDB: Number of pools: 1
2020-07-15 19:22:01 0 [Note] InnoDB: Using SSE4.2 crc32 instructions
2020-07-15 19:22:01 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
2020-07-15 19:22:01 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
2020-07-15 19:22:01 0 [Note] InnoDB: Completed initialization of buffer pool
2020-07-15 19:22:01 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-07-15 19:22:01 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=45069
2020-07-15 19:22:01 0 [Note] InnoDB: 128 rollback segments are active.
2020-07-15 19:22:01 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2020-07-15 19:22:01 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-07-15 19:22:01 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-07-15 19:22:02 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2020-07-15 19:22:02 0 [Note] InnoDB: 10.5.4 started; log sequence number 45081; transaction id 21
2020-07-15 19:22:02 0 [Note] Plugin 'FEEDBACK' is disabled.
2020-07-15 19:22:02 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2020-07-15 19:22:02 0 [Note] InnoDB: Buffer pool(s) load completed at 200715 19:22:02
2020-07-15 19:22:02 0 [Note] Server socket created on IP: '::'.
2020-07-15 19:22:02 0 [Warning] 'proxies_priv' entry '#% root#5666e0d8e52e' ignored in --skip-name-resolve mode.
2020-07-15 19:22:02 0 [Note] Reading of all Master_info entries succeeded
2020-07-15 19:22:02 0 [Note] Added new Master_info '' to hash table
2020-07-15 19:22:02 0 [Note] mysqld: ready for connections.
Version: '10.5.4-MariaDB-1:10.5.4+maria~focal' socket: '/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution
[Edit]
I logged into the CLI for the db container, and verified that my init.sql script is in the docker-entrypoint-initdb.d folder:
$ cd docker-entrypoint-initdb.d
$ ls
init.sql
$ pwd
/docker-entrypoint-initdb.d
Anyone have any ideas on what else to check?
I faced an identical issue and I investigated the logs more closely.
I wasn't sure if the following error was related but I decided to get rid of it.
ERROR 1396 (HY000) at line 1: Operation CREATE USER failed for 'root'#'%'
It seems that root user is created by default so I changed the environment variable of the user to user for example instead of root:
MYSQL_USER: user
After that I built and run the docker-compose.yml file and the SQL scripts executed succesfuly.
I had to reset the data volume otherwise the entry script would not trigger. In this case you would have to delete all contents:
sudo rm -rf /cms/conf/mysql/data/

Docker container won't start the mysql-client

My Dockerfile:
FROM mysql:5.6
ENV MYSQL_ROOT_PASSWORD=pass
ENV MYSQL_DATABASE=some_db
ENV MYSQL_USER=some_user
ENV MYSQL_PASSWORD=pass
i use this command to run a container
docker run --name mymysql --rm -it -p 3306:3306 mysql
the script start and stop here.
... some logs
MySQL init process done. Ready for start up.
2018-06-15 12:15:49 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-06-15 12:15:49 0 [Note] mysqld (mysqld 5.6.40) starting as process 1 ...
2018-06-15 12:15:49 1 [Note] Plugin 'FEDERATED' is disabled.
2018-06-15 12:15:49 1 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-06-15 12:15:49 1 [Note] InnoDB: The InnoDB memory heap is disabled
2018-06-15 12:15:49 1 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-06-15 12:15:49 1 [Note] InnoDB: Memory barrier is not used
2018-06-15 12:15:49 1 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-06-15 12:15:49 1 [Note] InnoDB: Using Linux native AIO
2018-06-15 12:15:49 1 [Note] InnoDB: Using CPU crc32 instructions
2018-06-15 12:15:49 1 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-06-15 12:15:49 1 [Note] InnoDB: Completed initialization of buffer pool
2018-06-15 12:15:49 1 [Note] InnoDB: Highest supported file format is Barracuda.
2018-06-15 12:15:49 1 [Note] InnoDB: 128 rollback segment(s) are active.
2018-06-15 12:15:49 1 [Note] InnoDB: Waiting for purge to start
2018-06-15 12:15:49 1 [Note] InnoDB: 5.6.40 started; log sequence number 1625997
2018-06-15 12:15:49 1 [Note] Server hostname (bind-address): '*'; port: 3306
2018-06-15 12:15:49 1 [Note] IPv6 is available.
2018-06-15 12:15:49 1 [Note] - '::' resolves to '::';
2018-06-15 12:15:49 1 [Note] Server socket created on IP: '::'.
2018-06-15 12:15:49 1 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2018-06-15 12:15:49 1 [Warning] 'proxies_priv' entry '# root#1804588a972e' ignored in --skip-name-resolve mode.
2018-06-15 12:15:49 1 [Note] Event Scheduler: Loaded 0 events
2018-06-15 12:15:49 1 [Note] mysqld: ready for connections.
Version: '5.6.40' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
....NOTHING HAPPENS
I need a command that run a container and start directly the mysql-client.

Resources