How to Allow Use of Larger Database Sizes in MySQL Docker Container on MacOS

Solution for How to Allow Use of Larger Database Sizes in MySQL Docker Container on MacOS
is Given Below:

I’m moving my grails application + MySQL database into docker containers through the use of docker-compose on my MacOS host machine. I have everything able to run successfully, but I need to import a large database file (16GB). Initially everything is importing fine, but after a bit I start getting errors that grails_mysql | 2021-08-02 21:55:16 1 [ERROR] mysqld: The table 'users' is full. A bit after getting a bunch of those errors, it quits out with the below error:

grails_mysql  | 2021-08-02 21:55:16 7fc7761017002021-08-02 21:55:16 1 [ERROR] InnoDB: Failure of system call pwrite(). Operating system error number is 28.
grails_mysql  | InnoDB: Error number 28 means 'No space left on device'.
grails_mysql  | InnoDB: Some operating system error numbers are described at
grails_mysql  | InnoDB: http://dev.mysql.com/doc/refman/5.6/en/operating-system-error-codes.html
grails_mysql  | 2021-08-02 21:55:16 1 [ERROR] mysqld: The table 'tabe_name' is full
grails_mysql  | InnoDB: Fatal error (Out of disk space) in rollback.
grails_mysql  | InnoDB: Out of tablespace.
grails_mysql  | InnoDB: Consider increasing your tablespace.

I assumed this means I needed to give docker more disk space, so I opened the docker GUI and went to the advanced settings and set Disk Image Size to 128GB, since that’s the only value in the settings related to disk space. However, when I try to run the container at all after making that change, I get this error: no space left on device: unknown.

Then after deleting the containers and trying again, same thing happened, so I don’t think that Disk Image Size value was the issue. How can I expand the disk space given to the database? (I have plenty of disk space on my host machine, so that’s not the issue).

docker-compose.yml:

version: '3.7'
services:
  grails:
    image: ibbrussell/grails:2.3.11
    command: run-app
    volumes:
      - ~/.m2:/root/.m2
      - ~/.gradle:/root/.gradle
      - ~/.grails:/root/.grails
      - ./:/app
    ports:
      - "8080:8080" #Grails default port
      - "5005:5005" #Grails debug port
    depends_on:
      - db
    deploy:
      resources:
        limits:
          memory: 4G
        reservations:
          memory: 4G
  db:
    image: mysql:5.6
    container_name: grails_mysql
    ports:
      - "3306:3306"
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD: 1
      MYSQL_DATABASE: grails
    volumes:
      - /usr/local/mysql_container:/var/lib/mysql

If it helps at all, this happens exactly when I submit 1GB of data into the database, so it seems like a value is defaulted to 1GB when it doesn’t need to be.

If this does not get resolved the ‘right way’ (by increasing the Docker disk allocation), consider the following:

Set up a “volume” so that the MySQL (inside Docker) will reach outside for its disk space.

It looks like Docker only allocated a small part of the 128G disk you set but not all of it. The real disk size can be expanded when it’s needed.

You may need check your Mac host’s real disk capacity. It’s probably less than 16Gb.
If it is, you can login the host and expand the disk space.

Increase container volume(disk) size

i think its better to clean up some extra unused images and containers and try again you can use

docker system prune

be-careful with this command because it removes all stoped containers and unused images. if you are not sure how to use this just remove them by hand

docker images

docker rmi <containerid>

after clean up just restart your docker app and start your container log into you container by

docker exec -it <containerID> bash

check out how much memory is available by

df -h