環境
Docker for mac Version (2.0.0.0-mac78)
mac OS 10.13.13 (High Sierra)
mysqlのコンテナを起動しようとすると、以下のように容量が足りないとエラーがでる。
現象
Initializing database
2018-12-25T21:43:30.931202Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use for_timestamp server option (see documentation for more details).
2018-12-25T21:43:30.935205Z 0 [Warning] InnoDB: Using innodb_file_format is deprecated and the parameter may be removed in http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
2018-12-25T21:43:30.961773Z 0 [Warning] InnoDB: Retry attempts for writing partial data failed.
2018-12-25T21:43:30.961810Z 0 [ERROR] InnoDB: Write to file ./ibdata1failed at offset 0, 1048576 bytes should have been written. Operating system error number 28. Check that your OS and file system support files of this size. Check also that the a disk quota exceeded.
2018-12-25T21:43:30.961820Z 0 [ERROR] InnoDB: Error number 28 means 'No space left on device'
2018-12-25T21:43:30.961825Z 0 [ERROR] InnoDB: Could not set the file size of './ibdata1'. Probably out of disk space
2018-12-25T21:43:30.961828Z 0 [ERROR] InnoDB: InnoDB Database creation was aborted with error Generic error. You may need to ile before trying to start up again.
2018-12-25T21:43:31.565477Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2018-12-25T21:43:31.565514Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2018-12-25T21:43:31.565518Z 0 [ERROR] Failed to initialize builtin plugins.
2018-12-25T21:43:31.565520Z 0 [ERROR] Aborting
調査
対象のコンテナを起動して容量を確認すると
ルート以下が容量100%になっている
/# df -h
Filesystem Size Used Avail Use% Mounted on
overlay 59G 56G 0 100% /
tmpfs 64M 0 64M 0% /dev
tmpfs 1000M 0 1000M 0% /sys/fs/cgroup
osxfs 421G 333G 85G 80% /etc/mysql/conf.d
/dev/sda1 59G 56G 0 100% /etc/hosts
shm 64M 0 64M 0% /dev/shm
tmpfs 1000M 0 1000M 0% /proc/acpi
tmpfs 1000M 0 1000M 0% /sys/firmware
docker volumeコマンドでvolumeを確認すると、使っていなそうなvolumeがたくさんある
$ docker volume ls
local 0a147b310b327a732d452aba0da74e7fcb745641d53654cd6f6013efefba3f7e
local 0b86da4bcda4bbde206e02104a9449040cc3b9e22290a4583bda816910a23f50
local 0bd0f647f099ccde83a9ec7ac6fefe41d754cf28183cffeb66f01cc05dd32316
local 0e23c68d181912fc998c66e6f313de61ac97cf62fe5c0af99b5a9e8f5c2254f4
...
解決方法
不要なvolumeを消すコマンドを実行
docker volume prune
これで半分以上消えた。
この状態で、mysqlのコンテナを再起動すると、
正常に起動できるようになった。