问题描述
一般情况是我们有一个服务器集群,我们要使用Docker设置虚拟集群。为此,我们创建了Dockerfiles对于不同的服务(Hadoop,Spark等)。
关于Hadoop HDFS服务,我们有这样的情况:docker容器可用的磁盘空间等于磁盘服务器可用的空间。我们希望在每个容器的基础上限制可用的磁盘空间,以便我们可以动态地生成一些额外的数据库,其中存储大小有助于HDFS文件系统。
有想法使用ext4格式化的环回文件,并将它们安装在我们用作docker容器中的卷的目录上。但是,这意味着很大的性能损失。
我发现了另一个问题(),但答案差不多1 5年了 - 关于docker开发的速度 - 是古老的。
哪种方式或存储后端将允许我们
- 限制每个容器的存储空间
- 具有近乎裸机的性能
- 不需要重新分区服务器驱动器
您可以指定,而不是磁盘空间。
已经请求对磁盘空间的限制(,),但isn没有实现,因为它取决于基础文件系统驱动程序。
更新2016年8月:如下所示,在,而已经被合并。 现在允许为每个容器设置存储驱动程序选项
$ docker run -it --storage-opt size = 120G fedora / bin / bash
The general scenario is that we have a cluster of servers and we want to set up virtual clusters on top of that using Docker.
For that we have created Dockerfiles for different services (Hadoop, Spark etc.).
Regarding the Hadoop HDFS service however, we have the situation that the disk space available to the docker containers equals to the disk space available to the server. We want to limit the available disk space on a per-container basis so that we can dynamically spawn an additional datanode with some storage size to contribute to the HDFS filesystem.
We had the idea to use loopback files formatted with ext4 and mount these on directories which we use as volumes in docker containers. However, this implies a large performance loss.
I found another question on SO (Limit disk size and bandwidth of a Docker container) but the answers are almost 1,5 years old which - regarding the speed of development of docker - is ancient.
Which way or storage backend would allow us to
- Limit storage on a per-container basis
- Has near bare-metal performance
- Doesn't require repartitioning of the server drives
You can specify runtime constraints on memory and CPU, but not disk space.
The ability to set constraints on disk space has been requested (issue 12462, issue 3804), but isn't yet implemented, as it depends on the underlying filesystem driver.
Update August 2016: as shown below, and in issue 3804 comment, PR 24771 and PR 24807 have seen then been merged. docker run
now allow to set storage driver options per container
$ docker run -it --storage-opt size=120G fedora /bin/bash
这篇关于如何限制Docker可用于容器的文件系统空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!