Docker: in memory file system

qballer picture qballer · Aug 28, 2016 · Viewed 17.3k times · Source

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.

Answer

BMitch picture BMitch · Sep 4, 2016

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