In my compose.yaml
I have this volume bind to my container mysql:
chatbot_database:
image: yukari268/primasbot:chatbot_database_JAN
container_name: chatbot_database
user: "1000:50"
command: [--ignore-db-dir=lost+found]
ports:
- 3306:3306
restart: unless-stopped
volumes:
- "chatbot_database_volume:/var/lib/mysql"
environment:
- MYSQL_ROOT_PASSWORD=root_password
healthcheck:
test: ["....."]
timeout: 20s
interval: 30s
start_period: 300s
retries: 5
volumes:
chatbot_database_volume:
driver: local
driver_opts:
type: none
o: bind
and i have a simple image using mysql as base image:
FROM mysql:8.2.0
WORKDIR /db
COPY init.sql /docker-entrypoint-initdb.d/
# Update my.cnf for more detailed error logging
RUN sed -i 's/bind-address\s*=\s*127\.0\.0\.1/bind-address = 0.0.0.0/' /etc/my.cnf && \
sed -i '/^#\s*log_error/s/^# //' /etc/my.cnf || \
echo "log_error = /var/log/mysql/error.log" >> /etc/my.cnf
I followed a thread on github “–initialize specified but the data directory has files in it” error when setting volume for subdirectories · Issue #757 · docker-library/mysql · GitHub added user: "1000:50"
to my service. and i also followed a Stack Overflow post php - Initializing mysql directory error - Stack Overflow. But none of the solution work i keep getting the error:
chatbot_database | 2024-01-23 04:35:11+00:00 [Note] [Entrypoint]: Initializing database files
chatbot_database | 2024-01-23T04:35:11.018564Z 0 [System] [MY-015017] [Server] MySQL Server Initialization - start.
chatbot_database | 2024-01-23T04:35:11.043003Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.2.0) initializing of server in progress as process 41
chatbot_database | 2024-01-23T04:35:11.047474Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
chatbot_database | 2024-01-23T04:35:11.047527Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
chatbot_database | 2024-01-23T04:35:11.050646Z 0 [ERROR] [MY-010119] [Server] Aborting
chatbot_database | 2024-01-23T04:35:11.050877Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.2.0) MySQL Community Server - GPL.
chatbot_database | 2024-01-23T04:35:11.051437Z 0 [System] [MY-015018] [Server] MySQL Server Initialization - end.
My OS:
root@debian11:~/compose# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 11 (bullseye)
Release: 11
Codename: bullseye
Docker version:
root@debian11:~/compose# docker version
Client: Docker Engine - Community
Version: 24.0.7
API version: 1.43
Go version: go1.20.10
Git commit: afdd53b
Built: Thu Oct 26 09:08:17 2023
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 24.0.7
API version: 1.43 (minimum version 1.12)
Go version: go1.20.10
Git commit: 311b9ff
Built: Thu Oct 26 09:08:17 2023
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.26
GitCommit: 3dd1e886e55dd695541fdcd67420c2888645a495
runc:
Version: 1.1.10
GitCommit: v1.1.10-0-g18a0cb0
docker-init:
Version: 0.19.0
GitCommit: de40ad0