How do you get around the size limitation of Docker.qcow2 in the Docker for Mac?

流过昼夜 提交于 2019-11-29 05:49:24

问题


I have a large (100gb+) database that I'm trying to run with the official postgres image.

I can't store the data in a docker volume because the ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2 file in Docker for Mac has a size limitation of about 60gb.

I'm hesitant to mount a host directory as a volume because file access in mounted host directory volumes is much slower than regular volumes.

These are some useful links that go into more detail on these issues:

  • This discusses the size limitation of the Docker.qcow2 file
  • This also discusses the size limitation of the Docker.qcow2 file
  • This discusses the mounted host directory volume speed issue
  • This gives a nice description of how to replace the Docker.qcow2 file with a file that can grow larger
  • This discusses how the Docker.qcow2 file doesn't shrink as its contents are removed (this isn't directly related, but can further complicate the problem)

Do you all just eat the speed loss and mount a host directory? Do you manually create a qcow2 file that can grow larger with qemu (if you do this, do you need to maintain this file between upgrades)? Do you do something else to handle this issue?


回答1:


The following script delete and re-create a new shrinked Docker.qcow2 file preserving the images passed as arguments.

https://blog.mrtrustor.net/post/clean-docker-for-mac/

Hope this helps.




回答2:


For a situation like this, I would definitely recommend creating a qcow image that can grow larger.

It is a relatively straightforward process, and you get the performance benefits that are generally quite necessary when running a large database.




回答3:


Docker for Mac 18.06 switches from the qcow2 file format to the raw file format, which improves speed and disk usage. The core issue still persists, in that Docker has a limited amount of space that it can use for all of its data. However, you can now set what that limit is within Preferences -> Disk -> Disk image size.

Docker for Mac version 17.12 was the first version to introduce the raw file format, but there were some bugs in the initial release that caused them to remove it as a feature temporarily. You can search that page for 'raw' to look back through the feature's history.

There's a great note here about how Docker for Mac reports its disk usage...

This will display the logical size:

ls -alh ~/Library/Containers/com.docker.docker/Data/vms/0/Docker.raw

While this will display the physical size:

du -h ~/Library/Containers/com.docker.docker/Data/vms/0/Docker.raw



来源:https://stackoverflow.com/questions/39402363/how-do-you-get-around-the-size-limitation-of-docker-qcow2-in-the-docker-for-mac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!