Next.js Discord

Discord Forum

Docker Error with MySQL Database

Unanswered
American black bear posted this in #help-forum
Open in Discord
American black bearOP
My docker-compose file
version: '3.9'

services:
  server:
    container_name: app-nest
    build: ./server
    volumes:
      - ./server:/src
      - /app/node_modules
    ports:
      - '3001:3001'
    environment:
      - DATABASE_URL=mysql://root:123456@db:3306/connectflow
    depends_on:
      - mysql
      - redis

  client:
    container_name: app-next
    build: ./client
    volumes:
      - ./client:/app
      - /app/node_modules
    ports:
      - '3000:3000'
    depends_on:
      - server

  mysql:
    container_name: mysql
    image: mysql:8.0
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: connectflow
      MYSQL_USER: user
      MYSQL_PASSWORD: 123456
    ports:
      - '3306:3306'
    volumes:
      - ./connectflow.sql:/docker-entrypoint-initdb.d/connectflow.sql:ro
      - db-data:/var/lib/mysql/data:rw

  redis:
    image: redis:latest
    ports:
      - 6379:6379/tcp

volumes:
  db-data:

36 Replies

American black bearOP
Error:
mysql                 | 2023-06-14 00:33:30+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
mysql                 | 2023-06-14 00:33:30+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.33-1.el8 started.
mysql                 | 2023-06-14 00:33:31+00:00 [Note] [Entrypoint]: Initializing database files
mysql                 | 2023-06-14T00:33:31.010907Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
mysql                 | 2023-06-14T00:33:31.016153Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.33) initializing of server in progress as process 80
mysql                 | 2023-06-14T00:33:31.017089Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
mysql                 | 2023-06-14T00:33:31.017094Z 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.
mysql                 | 2023-06-14T00:33:31.017135Z 0 [ERROR] [MY-010119] [Server] Aborting
mysql                 | 2023-06-14T00:33:31.017225Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.33)  MySQL Community Server - GPL.
System: Windows 10
Docker: v23.0.5, build bc4487a
Is that the entire error log?
Based on what the error says, /var/lib/mysql/data isnt empty
Have you tried using a different directory?
Maybe you can add the ignore option
like in the second answer?
@linesofcode Is that the entire error log?
American black bearOP
These are the logs that I see in vsc after typing "docker compose up"
American black bearOP
Still the same error
have you confirmed the directory is empty?
Besides that i'm not really sure
I've never seen this error before, my guess is as good as yours
Maybe something to do with permissions with the directory you're using?
American black bearOP
When I entered the mysql container, this path is empty.
And now in vsc in terminal I have even more errors than I had before adding to mysql "command: [--ignore-db-dir=lost+found]"
A lot of them suggest pruning your volumes (keep in mind this command will delete all data on your docker volumes, so be careful)
and then trying again
Good luck figuring this out, maybe someone else in this Discord is knowledgable on this can help you out
American black bearOP
Current terminal log:
The error says you dont have enough memory
which lines up with the suggestions of pruning your volumes (be careful, this will delete all data on your docker volumes)
or making additional space on your hard drive
American black bearOP
Yes, but I have enough space on my computer
you see
I believe docker has its own limit
In the settings of the app
Resources -> Advanced -> Virtual Disk Limit
American black bearOP
Is it enough to reset the machine or do I have to reinstall the wsl?
it's one of the prune commands
beyond that I'm not sure, I dont use WSL
I gotta go, best of luck figuring this out!
American black bearOP
I increased the limit to 2gb maybe it works now
I use wsl for redis and if I have wsl enabled in the system, docker uses it by default but I don't know because it's the first time I use docker