Creating tables in MySQL is incredibly slow in my containers. I have a single mysql container:
mysql:
image: mysql:5.5
volumes:
- mysqldata:/var/lib/mysql
- ./mysql/mysql.cnf:/etc/mysql/conf.d/mysql.cnf:ro
ports:
- "3306:3306"
environment:
- MYSQL_ROOT_PASSWORD=password
The mysqldata container was created with docker volume create --name=mysqldata
.
mysql.cnf contains:
[mysqld]
innodb_file_per_table=1
# WordPress's database includes many fields that support MEDIUMTEXT (i.e., ~16M)
max_allowed_packet=16M
skip-host-cache
skip-name-resolve
So this is a fairly standard MySQL container with data stored in a named volume (not mounted from a host directory).
Let’s take a fairly simple WP database. wp.sql · GitHub
Importing this DB takes about 25 seconds, when it should be nearly instantaneous (I’d even accept a couple seconds). Importing a dump of a few dozen MB can take an hour. As a dump is importing, the Activity Monitor in OSX reports that it’s writing at 2-3 MB/s.
What is it so busy writing? Why does MySQL take so long to import such a tiny (25KB) sql dump? How would I even start to analyze this to track down the cause?
I am currently on Docker for Mac Version 1.12.1-beta26.1, but I’ve been experiencing this on every version (both stable and beta) since I first installed beta8.