Docker for Macのディスクスループットを約2倍にする

Docker for Macのリリースノートを見てたら、

For systems running APFS on SSD on High Sierra, use raw format VM disks by default. This improves disk throughput (from 320MiB/sec to 600MiB/sec in dd on a 2015 MacBook Pro) and disk space handling.
Existing disks are kept in qcow format, if you want to switch to raw format you need to “Remove all data” or “Reset to factory defaults”

Docker Community Edition 17.12.0-ce-mac46 2018-01-09 (Stable)

Docker Community Edition 17.12.0-ce-mac46 2018-01-09 (Stable)の更新で、ディスクスループットが320MiB/secから600MiB/secになるらしいので適用する。

APFS, SSD, High Sierraで有効。
もう適用してしまったため効果測定できてないが、手順だけここにメモ。

一度初期化を行う

現状確認。
Disk image locationを見ると拡張子がqcow2になっている。

68747470733a2f2f71696974612d696d6167652d73746f72652e73332e616d617a6f6e6177732e636f6d2f302f39343333322f65323731356633332d633639622d306535652d303435622d3437346133336536626130332e706e67.png

仮想ディスクフォーマットを変更するには、一度Remove all dataまたはReset to factory defaultsを行う必要がある。
Reset to factory defaultsを行うと、使用CPUや使用メモリなどの設定も初期化されてしまうので、Remove all data を実施する。

image.png

新しいフォーマットで仮想ディスクイメージを作ってみる。

試しに $ docker run hello-world して新しい仮想ディスクイメージのフォーマットを確認してみる。

$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:66ef312bbac49c39a89aa9bcc3cb4f3c9e7de3788c944158df3ee0176d32b751
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

仮想ディスクイメージのlocationを確認してみると、拡張子がrawに変わっていることを確認。

68747470733a2f2f71696974612d696d6167652d73746f72652e73332e616d617a6f6e6177732e636f6d2f302f39343333322f38623161323739642d353062332d336236392d313634622d6336653936613064306361632e706e67.png

試しにddコマンド

事後しかないけど、 ddコマンドで10GB書き込んだ際のログを残しておきます。

  • MacBook Pro (Retina, 13-inch, Early 2015)
  • 2.7 GHz Intel Core i5
  • 8 GB 1867 MHz DDR3
$ docker run -it alpine time dd if=/dev/zero of=/test bs=262144 count=40960
40960+0 records in
40960+0 records out
real    1m 5.46s
user    0m 0.32s
sys     0m 36.67s
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account log in.