Clarencio
Clarencio

Reputation: 313

Performance issues with mysql docker container

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

Upvotes: 11

Views: 11276

Answers (2)

Suat Keskin
Suat Keskin

Reputation: 114

I did not encounter such a problem on my desktop, but mysql container was running very slowly in a way that I could not understand on my laptop computer. This solution solved my problem.

Upvotes: -2

Peter P
Peter P

Reputation: 501

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.

Upvotes: 9

Related Questions