Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performance issues with mysql docker container

Tags:

docker

mysql

I migrated my mysql database to docker and I restored a dump file. My mysql server was instaled directly on Linux, and I had not issues. On docker container my queries is 30x slower. Someone had a similar problem? I am running docker on Ubuntu 16 and I am using the following docker compose:

version: '3'
services:
  db:
    image: mysql:5.7
    environment:
      - MYSQL_ROOT_PASSWORD=root
    volumes:
      - ~/mysql/:/var/lib/mysql/
    ports:
      - "3306:3306"

  web:
    build: .
    volumes:
       - .:/var/www/html/app/
    ports:
      - "80:80"
    depends_on:
      - db
like image 282
Clarencio Avatar asked Apr 09 '26 03:04

Clarencio


1 Answers

don't know if it can still help you. Faced the same issue hence I tried to figure it out. Apparentley the volume from your host filesystem to the container slows it down dramatically. Try to use the following setup with your volume:

~/mysql/:/var/lib/mysql:delegated

The only draw back is that it might take some time until the data written inside /var/lib/mysql will be written to your local filesystem.

like image 167
Peter P Avatar answered Apr 10 '26 16:04

Peter P



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!