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

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/

Related

docker-compose seems to ignore .env-variables on mariadb

I'm having problems with docker-compose for a while now and can't figure out what's going on there. Given is the following scenario - which worked before but stopped working on a new project and now on every new stack I build up:
$ docker --version
Docker version 20.10.12, build e91ed57
$ docker-compose --version
Docker Compose version v2.2.2
OS: Pop!_OS 21.10 (NVIDIA)
Filestructure:
/myfolder
+ app-src (containing my laravel-project)
+ database-dumps (for database-dumps - containing a .gitkeep-file)
+ database_persist (for persistent data - containing a .gitkeep-file)
- .env
- .gitignore
- buildcontrainer.sh (custom script)
- container-start.sh (custom script)
- docker-compose.yml
- migrate-database.sh (custom script)
- README.md
This is the shortened docker-compose.yml-file (shortened, because it only affects the database... nginx and the php-container are working fine):
version: '3'
services:
database:
environment:
- MYSQL_DATABASE=${DB_DATABASE}
- MYSQL_USER=${DB_USER}
- MYSQL_PASSWORD=${DB_PASSWORD}
- MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
image: mariadb:10.6.1
ports:
- "${DB_EXPOSE_PORT}:3306"
volumes:
- "./database_persist:/var/lib/mysqldata"
And the .env-File:
COMPOSE_PROJECT_NAME=MyProject
DB_DATABASE="myprojectdb"
DB_USER="myproject"
DB_PASSWORD="12345"
DB_ROOT_PASSWORD="12345"
DB_EXPOSE_PORT=9036
WEB_EXPOSE_PORT_HTTP=9080
WEB_EXPOSE_PORT_HTTPS=9043
Now to my problem - whenever I try to set up an environment like given in the scenario and I run docker-compose build and docker-compose up afterwards I get the following output:
Creating network "myproject_default" with the default driver
Creating myproject_database_1 ... done
Attaching to myproject_database_1
database_1 | 2021-12-25 15:30:53+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.6.1+maria~focal started.
database_1 | 2021-12-25 15:30:53+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
database_1 | 2021-12-25 15:30:53+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.6.1+maria~focal started.
database_1 | 2021-12-25 15:30:53+00:00 [Note] [Entrypoint]: Initializing database files
database_1 | 2021-12-25 15:30:53 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
database_1 |
database_1 |
database_1 | PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
database_1 | To do so, start the server, then issue the following commands:
database_1 |
database_1 | '/usr/bin/mysqladmin' -u root password 'new-password'
database_1 | '/usr/bin/mysqladmin' -u root -h password 'new-password'
database_1 |
database_1 | Alternatively you can run:
database_1 | '/usr/bin/mysql_secure_installation'
database_1 |
database_1 | which will also give you the option of removing the test
database_1 | databases and anonymous user created by default. This is
database_1 | strongly recommended for production servers.
database_1 |
database_1 | See the MariaDB Knowledgebase at https://mariadb.com/kb or the
database_1 | MySQL manual for more instructions.
database_1 |
database_1 | Please report any problems at https://mariadb.org/jira
database_1 |
database_1 | The latest information about MariaDB is available at https://mariadb.org/.
database_1 | You can find additional information about the MySQL part at:
database_1 | https://dev.mysql.com
database_1 | Consider joining MariaDB's strong and vibrant community:
database_1 | https://mariadb.org/get-involved/
database_1 |
database_1 | 2021-12-25 15:30:57+00:00 [Note] [Entrypoint]: Database files initialized
database_1 | 2021-12-25 15:30:57+00:00 [Note] [Entrypoint]: Starting temporary server
database_1 | 2021-12-25 15:30:57+00:00 [Note] [Entrypoint]: Waiting for server startup
database_1 | 2021-12-25 15:30:57 0 [Note] mysqld (mysqld 10.6.1-MariaDB-1:10.6.1+maria~focal) starting as process 110 ...
database_1 | 2021-12-25 15:30:57 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
database_1 | 2021-12-25 15:30:57 0 [Note] InnoDB: Number of pools: 1
database_1 | 2021-12-25 15:30:57 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
database_1 | 2021-12-25 15:30:57 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
database_1 | 2021-12-25 15:30:57 0 [Note] InnoDB: Using Linux native AIO
database_1 | 2021-12-25 15:30:57 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
database_1 | 2021-12-25 15:30:57 0 [Note] InnoDB: Completed initialization of buffer pool
database_1 | 2021-12-25 15:30:57 0 [Note] InnoDB: 128 rollback segments are active.
database_1 | 2021-12-25 15:30:57 0 [Note] InnoDB: Creating shared tablespace for temporary tables
database_1 | 2021-12-25 15:30:57 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
database_1 | 2021-12-25 15:30:57 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
database_1 | 2021-12-25 15:30:57 0 [Note] InnoDB: 10.6.1 started; log sequence number 42616; transaction id 18
database_1 | 2021-12-25 15:30:57 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
database_1 | 2021-12-25 15:30:57 0 [Note] Plugin 'FEEDBACK' is disabled.
database_1 | 2021-12-25 15:30:57 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
database_1 | 2021-12-25 15:30:57 0 [Warning] 'user' entry 'root#66d18f02ea8a' ignored in --skip-name-resolve mode.
database_1 | 2021-12-25 15:30:57 0 [Warning] 'proxies_priv' entry '#% root#66d18f02ea8a' ignored in --skip-name-resolve mode.
database_1 | 2021-12-25 15:30:57 0 [Note] InnoDB: Buffer pool(s) load completed at 211225 15:30:57
database_1 | 2021-12-25 15:30:57 0 [Note] mysqld: ready for connections.
database_1 | Version: '10.6.1-MariaDB-1:10.6.1+maria~focal' socket: '/run/mysqld/mysqld.sock' port: 0 mariadb.org binary distribution
database_1 | 2021-12-25 15:30:58+00:00 [Note] [Entrypoint]: Temporary server started.
database_1 | Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
database_1 | Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it.
database_1 | Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it.
database_1 | 2021-12-25 15:31:01 5 [Warning] 'proxies_priv' entry '#% root#66d18f02ea8a' ignored in --skip-name-resolve mode.
database_1 | 2021-12-25 15:31:01+00:00 [Note] [Entrypoint]: Creating database myprojectdb
database_1 | 2021-12-25 15:31:01+00:00 [Note] [Entrypoint]: Creating user myproject
database_1 | 2021-12-25 15:31:01+00:00 [Note] [Entrypoint]: Giving user myproject access to schema myprojectdb
database_1 |
database_1 | 2021-12-25 15:31:01+00:00 [Note] [Entrypoint]: Stopping temporary server
database_1 | 2021-12-25 15:31:01 0 [Note] mysqld (initiated by: root[root] # localhost []): Normal shutdown
database_1 | 2021-12-25 15:31:01 0 [Note] InnoDB: FTS optimize thread exiting.
database_1 | 2021-12-25 15:31:01 0 [Note] InnoDB: Starting shutdown...
database_1 | 2021-12-25 15:31:01 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
database_1 | 2021-12-25 15:31:01 0 [Note] InnoDB: Buffer pool(s) dump completed at 211225 15:31:01
database_1 | 2021-12-25 15:31:01 0 [Note] InnoDB: Removed temporary tablespace data file: "./ibtmp1"
database_1 | 2021-12-25 15:31:01 0 [Note] InnoDB: Shutdown completed; log sequence number 42628; transaction id 19
database_1 | 2021-12-25 15:31:01 0 [Note] mysqld: Shutdown complete
database_1 |
database_1 | 2021-12-25 15:31:02+00:00 [Note] [Entrypoint]: Temporary server stopped
database_1 |
database_1 | 2021-12-25 15:31:02+00:00 [Note] [Entrypoint]: MariaDB init process done. Ready for start up.
database_1 |
database_1 | 2021-12-25 15:31:02 0 [Note] mysqld (mysqld 10.6.1-MariaDB-1:10.6.1+maria~focal) starting as process 1 ...
database_1 | 2021-12-25 15:31:02 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
database_1 | 2021-12-25 15:31:02 0 [Note] InnoDB: Number of pools: 1
database_1 | 2021-12-25 15:31:02 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
database_1 | 2021-12-25 15:31:02 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
database_1 | 2021-12-25 15:31:02 0 [Note] InnoDB: Using Linux native AIO
database_1 | 2021-12-25 15:31:02 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
database_1 | 2021-12-25 15:31:02 0 [Note] InnoDB: Completed initialization of buffer pool
database_1 | 2021-12-25 15:31:02 0 [Note] InnoDB: 128 rollback segments are active.
database_1 | 2021-12-25 15:31:02 0 [Note] InnoDB: Creating shared tablespace for temporary tables
database_1 | 2021-12-25 15:31:02 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
database_1 | 2021-12-25 15:31:02 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
database_1 | 2021-12-25 15:31:02 0 [Note] InnoDB: 10.6.1 started; log sequence number 42628; transaction id 18
database_1 | 2021-12-25 15:31:02 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
database_1 | 2021-12-25 15:31:02 0 [Note] Plugin 'FEEDBACK' is disabled.
database_1 | 2021-12-25 15:31:02 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
database_1 | 2021-12-25 15:31:02 0 [Note] Server socket created on IP: '0.0.0.0'.
database_1 | 2021-12-25 15:31:02 0 [Note] Server socket created on IP: '::'.
database_1 | 2021-12-25 15:31:02 0 [Warning] 'proxies_priv' entry '#% root#66d18f02ea8a' ignored in --skip-name-resolve mode.
database_1 | 2021-12-25 15:31:02 0 [Note] InnoDB: Buffer pool(s) load completed at 211225 15:31:02
database_1 | 2021-12-25 15:31:02 0 [Note] mysqld: ready for connections.
database_1 | Version: '10.6.1-MariaDB-1:10.6.1+maria~focal' socket: '/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution
It looks to me as if the .env-parameters are not given to the database-container anymore. All attempts recreating the database-container with docker-compose build, or removing all images via docker image prune and docker-compose pull have been in vain. I have updated my OS from 21.04 to 21.10 two days ago, but I don't think it causes the issue (just stated it here if it does). Does someone has an idea on how to fix this? Setting the MYSQL_ROOT_PASSWORD directly in the docker-compose.yml did not help either. The permission on database_persist are set via sudo chown -R $USER:$USER database_persist/ so that should not be an issue as well.
Thanks (and merry Christmas :) )
Edit: I tried reinstalling docker and updating docker-compose to version 2.2.2 (edited accordingly), but it had no effect. One of the commentors asked if I can connect to the container. Yes, I can, but not as root.
The .env file can be parsed as a part of the docker-compose.yaml. Though I personally never used this the way you do, as you can also pass a file directly into the container. With the env_file key
version: '3'
services:
database:
env_file: .env
image: mariadb:10.6.1
ports:
- "${DB_EXPOSE_PORT}:3306"
volumes:
- "./database_persist:/var/lib/mysqldata"
Obviously, you then also need to change the variable names in your .env file. And I personally would rename it to a more clear name.
Okay - for some weird reason the output stays the same, but when I try to login the dbroot and the dbuser actually use their passwords specified in the env-files. Plus using anything else will result in a "access denied". So I don't know if the update fixed the issue or if the logoutput just scared me and this is actually the expected behaviour. I will update this if I get any new insights.

docker-compose with adminer & mariadb shows 403 on attempted database connection

I have spent the last few hours debugging my system and I am at a loss as to what is going on here.
I am using a simple docker-compose.yml file to start a mariadb and an adminer instance on my Ubuntu 20.04 LTS system.
docker-compose.yml:
version: '3'
services:
database:
image: mariadb
restart: always
environment:
MYSQL_DATABASE: feedback
MYSQL_USER: db_user
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: root
adminer:
image: adminer
restart: always
environment:
ADMINER_DEFAULT_SERVER: database
ports:
- "127.0.0.1:8080:8080"
A coworker tested this and it works 100% of the time on their system. However, it only worked twice out of many, many tries in the last few hours one my system.
This is the docker-compose output:
Creating knowledge-base_database_1 ... done
Creating knowledge-base_adminer_1 ... done
Attaching to knowledge-base_adminer_1, knowledge-base_database_1
database_1 | 2021-05-31 12:17:04+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.5.10+maria~focal started.
adminer_1 | [Mon May 31 12:17:04 2021] PHP 7.4.19 Development Server (http://[::]:8080) started
database_1 | 2021-05-31 12:17:04+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
database_1 | 2021-05-31 12:17:04+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.5.10+maria~focal started.
database_1 | 2021-05-31 12:17:05+00:00 [Note] [Entrypoint]: Initializing database files
database_1 |
database_1 |
database_1 | PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
database_1 | To do so, start the server, then issue the following command:
database_1 |
database_1 | '/usr/bin/mysql_secure_installation'
database_1 |
database_1 | which will also give you the option of removing the test
database_1 | databases and anonymous user created by default. This is
database_1 | strongly recommended for production servers.
database_1 |
database_1 | See the MariaDB Knowledgebase at https://mariadb.com/kb or the
database_1 | MySQL manual for more instructions.
database_1 |
database_1 | Please report any problems at https://mariadb.org/jira
database_1 |
database_1 | The latest information about MariaDB is available at https://mariadb.org/.
database_1 | You can find additional information about the MySQL part at:
database_1 | https://dev.mysql.com
database_1 | Consider joining MariaDB's strong and vibrant community:
database_1 | https://mariadb.org/get-involved/
database_1 |
database_1 | 2021-05-31 12:17:06+00:00 [Note] [Entrypoint]: Database files initialized
database_1 | 2021-05-31 12:17:06+00:00 [Note] [Entrypoint]: Starting temporary server
database_1 | 2021-05-31 12:17:06+00:00 [Note] [Entrypoint]: Waiting for server startup
database_1 | 2021-05-31 12:17:06 0 [Note] mysqld (mysqld 10.5.10-MariaDB-1:10.5.10+maria~focal) starting as process 99 ...
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: Uses event mutexes
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: Number of pools: 1
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
database_1 | 2021-05-31 12:17:06 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: Using Linux native AIO
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: Completed initialization of buffer pool
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: 128 rollback segments are active.
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: Creating shared tablespace for temporary tables
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: 10.5.10 started; log sequence number 45118; transaction id 20
database_1 | 2021-05-31 12:17:06 0 [Note] Plugin 'FEEDBACK' is disabled.
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: Buffer pool(s) load completed at 210531 12:17:06
database_1 | 2021-05-31 12:17:06 0 [Warning] 'user' entry 'root#5315aa145a33' ignored in --skip-name-resolve mode.
database_1 | 2021-05-31 12:17:06 0 [Warning] 'proxies_priv' entry '#% root#5315aa145a33' ignored in --skip-name-resolve mode.
database_1 | 2021-05-31 12:17:06 0 [Note] Reading of all Master_info entries succeeded
database_1 | 2021-05-31 12:17:06 0 [Note] Added new Master_info '' to hash table
database_1 | 2021-05-31 12:17:06 0 [Note] mysqld: ready for connections.
database_1 | Version: '10.5.10-MariaDB-1:10.5.10+maria~focal' socket: '/run/mysqld/mysqld.sock' port: 0 mariadb.org binary distribution
database_1 | 2021-05-31 12:17:07+00:00 [Note] [Entrypoint]: Temporary server started.
database_1 | Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
database_1 | Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it.
database_1 | Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it.
database_1 | 2021-05-31 12:17:09 5 [Warning] 'proxies_priv' entry '#% root#5315aa145a33' ignored in --skip-name-resolve mode.
database_1 | 2021-05-31 12:17:09+00:00 [Note] [Entrypoint]: Creating database feedback
database_1 | 2021-05-31 12:17:09+00:00 [Note] [Entrypoint]: Creating user db_user
database_1 | 2021-05-31 12:17:09+00:00 [Note] [Entrypoint]: Giving user db_user access to schema feedback
database_1 |
database_1 | 2021-05-31 12:17:09+00:00 [Note] [Entrypoint]: Stopping temporary server
database_1 | 2021-05-31 12:17:09 0 [Note] mysqld (initiated by: root[root] # localhost []): Normal shutdown
database_1 | 2021-05-31 12:17:09 0 [Note] Event Scheduler: Purging the queue. 0 events
database_1 | 2021-05-31 12:17:09 0 [Note] InnoDB: FTS optimize thread exiting.
database_1 | 2021-05-31 12:17:09 0 [Note] InnoDB: Starting shutdown...
database_1 | 2021-05-31 12:17:09 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
database_1 | 2021-05-31 12:17:09 0 [Note] InnoDB: Buffer pool(s) dump completed at 210531 12:17:09
database_1 | 2021-05-31 12:17:09 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
database_1 | 2021-05-31 12:17:09 0 [Note] InnoDB: Shutdown completed; log sequence number 45130; transaction id 21
database_1 | 2021-05-31 12:17:09 0 [Note] mysqld: Shutdown complete
database_1 |
database_1 | 2021-05-31 12:17:10+00:00 [Note] [Entrypoint]: Temporary server stopped
database_1 |
database_1 | 2021-05-31 12:17:10+00:00 [Note] [Entrypoint]: MariaDB init process done. Ready for start up.
database_1 |
database_1 | 2021-05-31 12:17:10 0 [Note] mysqld (mysqld 10.5.10-MariaDB-1:10.5.10+maria~focal) starting as process 1 ...
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: Uses event mutexes
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: Number of pools: 1
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
database_1 | 2021-05-31 12:17:10 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: Using Linux native AIO
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: Completed initialization of buffer pool
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: 128 rollback segments are active.
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: Creating shared tablespace for temporary tables
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: 10.5.10 started; log sequence number 45130; transaction id 20
database_1 | 2021-05-31 12:17:10 0 [Note] Plugin 'FEEDBACK' is disabled.
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: Buffer pool(s) load completed at 210531 12:17:10
database_1 | 2021-05-31 12:17:10 0 [Note] Server socket created on IP: '::'.
database_1 | 2021-05-31 12:17:10 0 [Warning] 'proxies_priv' entry '#% root#5315aa145a33' ignored in --skip-name-resolve mode.
database_1 | 2021-05-31 12:17:10 0 [Note] Reading of all Master_info entries succeeded
database_1 | 2021-05-31 12:17:10 0 [Note] Added new Master_info '' to hash table
database_1 | 2021-05-31 12:17:10 0 [Note] mysqld: ready for connections.
database_1 | Version: '10.5.10-MariaDB-1:10.5.10+maria~focal' socket: '/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution
Trying to log into the database with adminer using root:root produces the following output:
adminer_1 | [Mon May 31 12:17:54 2021] [::ffff:172.25.0.1]:38170 Accepted
adminer_1 | [Mon May 31 12:17:54 2021] [::ffff:172.25.0.1]:38170 [302]: POST /?server=database&username=root
adminer_1 | [Mon May 31 12:17:54 2021] [::ffff:172.25.0.1]:38170 Closing
adminer_1 | [Mon May 31 12:17:54 2021] [::ffff:172.25.0.1]:38174 Accepted
adminer_1 | [Mon May 31 12:18:24 2021] [::ffff:172.25.0.1]:38174 [403]: GET /?server=database&username=root
adminer_1 | [Mon May 31 12:18:24 2021] [::ffff:172.25.0.1]:38174 Closing
adminer_1 | [Mon May 31 12:18:24 2021] [::ffff:172.25.0.1]:38208 Accepted
adminer_1 | [Mon May 31 12:18:24 2021] [::ffff:172.25.0.1]:38208 [200]: GET /?file=favicon.ico&version=4.8.0
adminer_1 | [Mon May 31 12:18:24 2021] [::ffff:172.25.0.1]:38208 Closing
I have tried disabling my firewall, reinstalling docker and docker-compose, creating a custom network with docker instead of using docker-compose's default network, etc.
I also started a known-working project on my system, which yielded the same results. Something on my system seems to be broken, but I don't know where to look anymore.
Does anyone have any ideas what I can try to get this working?
Try appending /index.php so instead of http://localhost go to http://localhost/index.php

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 - mysql db getting installed but user not getting created

I am trying to create a hybrid container.
Following is my docker-compose file.
version: "2"
services:
database:
build:
context: ./registration-database
image: registration-database
# set default mysql root password, change as needed
environment:
MYSQL_ROOT_PASSWORD: password
# Expose port 3306 to host.
ports:
- "3306:3306"
restart: always
webserver:
build:
context: ./registration-webserver
image: registration-webserver
# mount point for application in tomcat
volumes:
- ./app/target/UserSignup:/usr/local/tomcat/webapps/UserSignup
links:
- database:registration-database
# open ports for tomcat and remote debugging
ports:
- "8080:8080"
- "8000:8000"
restart: always
Following is the dockerFile for mysql:
FROM mysql:5.7
# Copy the database initialize script:
# Contents of /docker-entrypoint-initdb.d are run on mysqld startup
ADD docker-entrypoint-initdb.d/ /docker-entrypoint-initdb.d/
ENV MYSQL_DATABASE=ishan
ENV MYSQL_USER=ishan
ENV MYSQL_PASSWORD=password
Following is the initialize_db.sql file
USE `ishan`;
CREATE TABLE `user` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`dateOfBirth` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ,
`emailAddress` varchar(255) NOT NULL,
`firstName` varchar(255) NOT NULL,
`lastName` varchar(255) NOT NULL,
`password` varchar(8) NOT NULL,
`userName` varchar(20) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=latin1;
Earlier when I was running the command docker-compose up it was creating the user ishan and it was creating the user table also. But now, suddenly something happened although the mysql is getting installed with the root user but the new user (ishan) and the table is not getting created. Any help is appreciated.
Following is the log which is getting printed on startup:
Starting app_database_1 ... done
Starting app_webserver_1 ... done
Attaching to app_database_1, app_webserver_1
database_1 | 2019-04-09T08:30:51.326732Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
database_1 | 2019-04-09T08:30:51.327850Z 0 [Note] mysqld (mysqld 5.7.25) starting as process 1 ...
database_1 | 2019-04-09T08:30:51.330081Z 0 [Note] InnoDB: PUNCH HOLE support available
database_1 | 2019-04-09T08:30:51.330114Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
database_1 | 2019-04-09T08:30:51.330118Z 0 [Note] InnoDB: Uses event mutexes
database_1 | 2019-04-09T08:30:51.330121Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
database_1 | 2019-04-09T08:30:51.330125Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
database_1 | 2019-04-09T08:30:51.330127Z 0 [Note] InnoDB: Using Linux native AIO
database_1 | 2019-04-09T08:30:51.330295Z 0 [Note] InnoDB: Number of pools: 1
database_1 | 2019-04-09T08:30:51.330382Z 0 [Note] InnoDB: Using CPU crc32 instructions
database_1 | 2019-04-09T08:30:51.331394Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
database_1 | 2019-04-09T08:30:51.336481Z 0 [Note] InnoDB: Completed initialization of buffer pool
database_1 | 2019-04-09T08:30:51.338022Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
database_1 | 2019-04-09T08:30:51.356556Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
database_1 | 2019-04-09T08:30:51.372677Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
database_1 | 2019-04-09T08:30:51.372933Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
database_1 | 2019-04-09T08:30:51.398496Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
database_1 | 2019-04-09T08:30:51.399884Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
database_1 | 2019-04-09T08:30:51.399990Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
database_1 | 2019-04-09T08:30:51.400792Z 0 [Note] InnoDB: 5.7.25 started; log sequence number 12359503
database_1 | 2019-04-09T08:30:51.401039Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
database_1 | 2019-04-09T08:30:51.401382Z 0 [Note] Plugin 'FEDERATED' is disabled.
database_1 | 2019-04-09T08:30:51.419097Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
database_1 | 2019-04-09T08:30:51.421195Z 0 [Warning] CA certificate ca.pem is self signed.
database_1 | 2019-04-09T08:30:51.423199Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
database_1 | 2019-04-09T08:30:51.423332Z 0 [Note] IPv6 is available.
database_1 | 2019-04-09T08:30:51.423468Z 0 [Note] - '::' resolves to '::';
database_1 | 2019-04-09T08:30:51.423622Z 0 [Note] Server socket created on IP: '::'.
database_1 | 2019-04-09T08:30:51.430839Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
database_1 | 2019-04-09T08:30:51.434012Z 0 [Note] InnoDB: Buffer pool(s) load completed at 190409 8:30:51
database_1 | 2019-04-09T08:30:51.437767Z 0 [Warning] 'user' entry 'root#localhost' ignored in --skip-name-resolve mode.
database_1 | 2019-04-09T08:30:51.437887Z 0 [Warning] 'user' entry 'mysql.session#localhost' ignored in --skip-name-resolve mode.
database_1 | 2019-04-09T08:30:51.438037Z 0 [Warning] 'user' entry 'mysql.sys#localhost' ignored in --skip-name-resolve mode.
database_1 | 2019-04-09T08:30:51.438612Z 0 [Warning] 'db' entry 'performance_schema mysql.session#localhost' ignored in --skip-name-resolve mode.
database_1 | 2019-04-09T08:30:51.438712Z 0 [Warning] 'db' entry 'sys mysql.sys#localhost' ignored in --skip-name-resolve mode.
database_1 | 2019-04-09T08:30:51.439004Z 0 [Warning] 'proxies_priv' entry '# root#localhost' ignored in --skip-name-resolve mode.
database_1 | 2019-04-09T08:30:51.451035Z 0 [Warning] 'tables_priv' entry 'user mysql.session#localhost' ignored in --skip-name-resolve mode.
database_1 | 2019-04-09T08:30:51.451161Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys#localhost' ignored in --skip-name-resolve mode.
database_1 | 2019-04-09T08:30:51.484566Z 0 [Note] Event Scheduler: Loaded 0 events
database_1 | 2019-04-09T08:30:51.485090Z 0 [Note] mysqld: ready for connections.
database_1 | Version: '5.7.25' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
Most probably your volume is still present and for that reason MySQL ignores the entrypoint folder. You need to delete the volume between runs to get a fresh start. Be aware that this means losing data saved in mysql in the meantime.
docker-compose down
# this will clean all volumes not in use by any containers
docker volume prune
Run docker volume ls to make sure your volume is gone and then run your docker-compose again.

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