简体   繁体   English

你如何解决Docker for Mac中Docker.qcow2的大小限制?

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

I have a large (100gb+) database that I'm trying to run with the official postgres image . 我有一个大型(100gb +)数据库,我正在尝试使用官方postgres图像运行。

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. 我无法将数据存储在~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2卷中,因为Docker for Mac中的~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2文件的大小限制为约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 讨论了Docker.qcow2文件的大小限制
  • This also discusses the size limitation of the Docker.qcow2 file 也讨论了Docker.qcow2文件的大小限制
  • 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 给出了如何用可以变大的文件替换Docker.qcow2文件的很好的描述
  • 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) 讨论了Docker.qcow2文件如何在其内容被删除时不缩小(这不是直接相关的,但可能会使问题进一步复杂化)

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)? 你手动创建一个qcow文件,可以用qemu增大(如果这样做,你需要在升级之间维护这个文件)吗? Do you do something else to handle this issue? 你还有别的办法处理这个问题吗?

The following script delete and re-create a new shrinked Docker.qcow2 file preserving the images passed as arguments. 以下脚本删除并重新创建一个新的缩小的Docker.qcow2文件,保留作为参数传递的图像。

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

Hope this helps. 希望这可以帮助。

For a situation like this, I would definitely recommend creating a qcow image that can grow larger. 对于这种情况,我肯定会建议创建一个可以变大的qcow图像。

It is a relatively straightforward process, and you get the performance benefits that are generally quite necessary when running a large database. 这是一个相对简单的过程,您可以获得运行大型数据库时通常非常必要的性能优势。

Docker for Mac 18.06 switches from the qcow2 file format to the raw file format, which improves speed and disk usage. Docker for Mac 18.06从qcow2文件格式切换到原始文件格式,从而提高了速度和磁盘使用率。 The core issue still persists, in that Docker has a limited amount of space that it can use for all of its data. 核心问题仍然存在,因为Docker的空间有限,可以用于所有数据。 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. Docker for Mac版本17.12是第一个引入原始文件格式的版本,但初始版本中有一些错误导致它们暂时将其作为一项功能删除。 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... 关于Docker for Mac如何报告其磁盘使用情况, 这里有一个很好的说明......

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM