I'm trying to add mysql to my docker project but I keep getting an error
db_1 | 2020-06-05T18:09:28.588053Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.20) initializing of server in progress as process 43
db_1 | 2020-06-05T18:09:28.611235Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
db_1 | 2020-06-05T18:09:28.611255Z 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.
db_1 | 2020-06-05T18:09:28.613001Z 0 [ERROR] [MY-010119] [Server] Aborting
db_1 | 2020-06-05T18:09:28.613491Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.20) MySQL Community Server - GPL.
When I do docker ps
I see
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9f561510f33d frontend "docker-entrypoint.s…" 4 minutes ago Up 4 minutes 0.0.0.0:3000->3000/tcp frontend_1
2c3f88dc6f6b backend "python3 manage.py r…" 5 minutes ago Up 5 minutes 0.0.0.0:8000->8000/tcp backend_1
d0768da38e93 mysql:latest "docker-entrypoint.s…" 5 minutes ago Restarting (1) 24 seconds ago db_1
I cd into var/lib
for container 2c3f88dc6f6b
and don't see a mysql dir. Not sure if that might be the issue but if it is why isnt there a mysql folder?
Why am I seeing that error?
docker-compose.yml
version: "3.2"
services:
backend:
build: ./backend
volumes:
- ./backend:/app/backend
ports:
- "8000:8000"
stdin_open: true
tty: true
command: python3 manage.py runserver 0.0.0.0:8000
links:
- db
frontend:
build: ./frontend
volumes:
- ./frontend:/app
# One-way volume to use node_modules from inside image
- /app/node_modules
ports:
- "3000:3000"
environment:
- NODE_ENV=development
- CHOKIDAR_USEPOLLING=true
depends_on:
- backend
tty: true
command: npm start
db:
image: mysql:latest
restart: always
volumes:
- "./.mysql/db:/var/lib/mysql"
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: test
MYSQL_USER: root
MYSQL_PASSWORD: root
ports:
- "3306:3306"