Score:1

Docker mysql volume size is larger than the database size

ru flag

Running a staging server using docker-componse.yml configuration, which has a MySQL service running with the following configuration

services:
  database:
    image: mysql:8.0.17
    container_name: qcg__staging__database
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    volumes:
      - qcg7_staging_db:/var/lib/mysql
    environment:
      - MYSQL_DATABASE=app_staging
      - MYSQL_USER=app_staging
      - MYSQL_PASSWORD=app_staging
      - MYSQL_ROOT_PASSWORD=app_staging
    ports:
      - 3306:3306

volumes:
  qcg7_staging_db:

Every time a code is pushed to the staging server, the docker containers are stopped and restarted using the following command

docker-compose down --remove-orphans
docker-compose -f docker-compose-staging.yml up --build -d

After few days of usages, the volume usages of the database reach 40GB which the actual data size in the database is 2.3 GiB

# docker system df -v

Local Volumes space usage:

VOLUME NAME                         LINKS     SIZE
qcg-backend_qcg7_staging_db         1         20.06GB

The output of Workbench database inspect

enter image description here

Michael Hampton avatar
cz flag
So what is taking up all the space? You can just go and look.
Anuj TBE avatar
ru flag
@MichaelHampton where to look? The database size is 2.3 GB and the volume size is 20 GB. Not sure where to check.
Michael Hampton avatar
cz flag
Look at the actual sizes of the actual files. Use tools like `du` and `ls`.
halloei avatar
us flag
I ran into the same issue yesterday. I found that [MySQL's Binary Logs](https://dev.mysql.com/doc/refman/8.0/en/binary-log.html) were making up the majority of my volume size. As I don't need such functionality, I've added `"--disable-log-bin"` to the service command.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.