Docker: in memory file system

别等时光非礼了梦想. 提交于 2020-12-27 17:03:50

问题


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.

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.


回答1:


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.

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



回答2:


Docker stores image, container, and volume data in its directory by default. Container HDs are made of the original image and the 'container layer'.

You might be able set this up using a RAM disk. You would hard allocate some RAM, mount it, and format it with your file system of choice. Then move your docker installation to the mounted RAM disk and symlink it back to the original location.

Setting up a Ram Disk

Best way to move the Docker directory

Obviously this is only useful for testing as Docker and it's images, volumes, containers, etc would be lost on reboot.



来源:https://stackoverflow.com/questions/39193419/docker-in-memory-file-system

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