Docker:内存文件系统中 [英] Docker: in memory file system

查看:72
本文介绍了Docker:内存文件系统中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Docker容器,可以对磁盘进行很多读/写操作.我想测试一下整个docker文件系统在内存中时会发生什么.我在这里看到了一些答案,说这不是真正的性能改进,但这是为了测试.

I have a docker container which does alot of read/write to disk. I would like to test out what happens when my entire docker filesystem is in memory. I have seen some answers here that say it will not be a real performance improvement, but this is for testing.

我要测试的理想解决方案是共享每个图像的公共部分,并在需要时复制到您的内存空间.

The ideal solution I would like to test is sharing the common parts of each image and copy to your memory space when needed.

在运行时创建的每个容器文件也应该在内存中并分开.闲置时间不应超过5GB fs,处理时间不应超过7GB.

Each container files which are created during runtime should be in memory as well and separated. it shouldn't be more than 5GB fs in idle time and up to 7GB in processing time.

简单的解决方案将为每个容器复制所有共享文件(甚至是您从未使用过的操作系统的那些部分).

Simple solutions would duplicate all shared files (even those part of the OS you never use) for each container.

推荐答案

图像的存储与容器的基本文件系统之间没有区别,分层的FS通过容器直接作为RO层访问图像层使用上方的RW层捕获任何更改.因此,要使容器在Docker安装仍保留在磁盘上的同时在内存中运行的目标实现起来并不容易.

There's no difference between the storage of the image and the base filesystem of the container, the layered FS accesses the images layers directly as a RO layer, with the container using a RW layer above to catch any changes. Therefore your goal of having the container running in memory while the Docker installation remains on disk doesn't have an easy implementation.

如果您知道您的RW活动发生在哪里(检查正在运行的容器的 docker diff 很容易),对我来说最好的选择是将tmpfs安装在容器中的该位置,这是docker本身支持的(来自 docker运行参考):

If you know where your RW activity is occurring (it's fairly easy to check the docker diff of a running container), the best option to me would be a tmpfs mounted at that location in your container, which is natively supported by docker (from the docker run reference):

$ docker run -d --tmpfs /run:rw,noexec,nosuid,size=65536k my_image

这篇关于Docker:内存文件系统中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆