Answers: <p>This means that you can start a container where the /host directory is the / directory on your host; and the container can alter your host file system without any restriction. This is similar to how virtualization systems allow file system resource sharing.</p>
  
  <p>Docker containers are very similar to LXC containers, and they have similar security features. When you start a container with docker run, behind the scenes Docker creates a set of namespaces and control groups for the container.</p>
  
Answers: CC BY-SA 4.0
Answers: 2020-02-03T04:51:52.897Z
Answers: 2020-02-03T04:51:52.897Z
Answers: Mitwa Nair
Answers: <p>Kubernetes can mount a ram disk for you. The answer is right there in the standard RTFM guide. </p>
  
  <p><a href="https://kubernetes.io/docs/concepts/storage/volumes/#emptydir" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/storage/volumes/#emptydir</a></p>
  
  <p>Create an <code>emptyDir</code> volume and set <code>emptyDir.medium</code> to "Memory" to build, what I interpret from the documentation to be, a dynamically sized memory file system which counts against the containers memory limit.</p>
  
  <p>If you're not running under kubernetes, whatever system that deploys the docker container would need to create the ram disk and mount that into the container, or give the container the special permissions discussed in the various reference articles in the question.</p>
  
Answers: CC BY-SA 4.0
Answers: 2022-09-25T06:13:44.570Z
Answers: Thank you for your answer, but please be considerate in your choice of words; "RTFM" and "right there" can be perceived as belittling and patronising, and everyone has different skill and comprehension levels :)
Answers: Jules
Answers: CC BY-SA 4.0
Answers: 2022-09-26T16:29:32.903Z
Answers: Ah, yes, but I was only belittling myself as it's an answer to my own question, and I'm probably a fair judge of when I deserved it, and I thought I deserved it just a little. :)  I wouldn't be so harsh a critic of anyone else.
Answers: David Parks
Answers: CC BY-SA 4.0
Answers: 2022-09-27T14:06:21.683Z
Answers: I didn't see that! Wow, serves me right for scrolling SO that late at night. Where's the self-love?!
Answers: Jules
Answers: CC BY-SA 4.0
Answers: 2020-02-02T02:43:46.657Z
Answers: 2020-02-02T02:43:46.657Z
Answers: David Parks
Body: <p>I'd like to create an in-memory filesystem within a docker container running on a cluster where I can't assign the container any special permissions (e.g. the container can't have <code>CAP_SYS_ADMIN</code> capability necessary for using <code>mount</code>).</p>
  
  <p>Is it possible to create an in-memory filesystem under docker? Will one of the user space filesystems provide this functionality?</p>
  
  <p>Reference article(s):</p>
  
  <ul>
  <li><a href="https://www.linuxtoday.com/blog/user-space-file-systems.html" rel="nofollow noreferrer">User Space File Systems</a></li>
  <li><a href="https://stackoverflow.com/questions/36553617/how-do-i-mount-bind-inside-a-docker-container">How do I mount --bind inside a Docker container?</a></li>
  <li><a href="https://stackoverflow.com/questions/48402218/fuse-inside-docker">FUSE inside Docker</a></li>
  <li><a href="https://github.com/thegreyd/FuseFilesystem" rel="nofollow noreferrer">An in-memory filesystem (ie, RAMDISK) using FUSE</a></li>
  <li><a href="https://stackoverflow.com/questions/51263555/riofs-fuse-device-not-found">Riofs - fuse device not found</a></li>
  </ul>
  
  <p>UPDATE: After finding and reading the references added above it's looking more and more like the answer is a firm no. I'll leave this open a bit in case anyone wants to elaborate or correct me.</p>
  
Tags: <docker><kubernetes>
Title: Can an in-memory filesystem be created from inside a docker container with no special permissions?
UserDisplayName: David Parks
ThreadText: # Can an in-memory filesystem be created from inside a docker container with no special permissions?
  
  (Asked by: username_0 on 2020-02-01)
  
  I'd like to create an in-memory filesystem within a docker container running on a cluster where I can't assign the container any special permissions (e.g. the container can't have `CAP_SYS_ADMIN` capability necessary for using `mount`).
  
  Is it possible to create an in-memory filesystem under docker? Will one of the user space filesystems provide this functionality?
  
  Reference article(s):
  
  * [User Space File Systems](https://www.linuxtoday.com/blog/user-space-file-systems.html)
  * [How do I mount --bind inside a Docker container?](https://stackoverflow.com/questions/36553617/how-do-i-mount-bind-inside-a-docker-container)
  * [FUSE inside Docker](https://stackoverflow.com/questions/48402218/fuse-inside-docker)
  * [An in-memory filesystem (ie, RAMDISK) using FUSE](https://github.com/thegreyd/FuseFilesystem)
  * [Riofs - fuse device not found](https://stackoverflow.com/questions/51263555/riofs-fuse-device-not-found)
  
  UPDATE: After finding and reading the references added above it's looking more and more like the answer is a firm no. I'll leave this open a bit in case anyone wants to elaborate or correct me.
  
  **Tags:** docker, kubernetes
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2020-02-02. Score: 3 | Accepted answer
  
  Kubernetes can mount a ram disk for you. The answer is right there in the standard RTFM guide.
  
  <https://kubernetes.io/docs/concepts/storage/volumes/#emptydir>
  
  Create an `emptyDir` volume and set `emptyDir.medium` to "Memory" to build, what I interpret from the documentation to be, a dynamically sized memory file system which counts against the containers memory limit.
  
  If you're not running under kubernetes, whatever system that deploys the docker container would need to create the ram disk and mount that into the container, or give the container the special permissions discussed in the various reference articles in the question.
  
  > **Comments:**
  > **username_2**: Thank you for your answer, but please be considerate in your choice of words; "RTFM" and "right there" can be perceived as belittling and patronising, and everyone has different skill and comprehension levels :)  
  > **username_0**: Ah, yes, but I was only belittling myself as it's an answer to my own question, and I'm probably a fair judge of when I deserved it, and I thought I deserved it just a little. :)  I wouldn't be so harsh a critic of anyone else.  
  > **username_2**: I didn't see that! Wow, serves me right for scrolling SO that late at night. Where's the self-love?!  
  
  ---
  
  ### Answer by username_1 on 2020-02-03. Score: 0
  
  This means that you can start a container where the /host directory is the / directory on your host; and the container can alter your host file system without any restriction. This is similar to how virtualization systems allow file system resource sharing.
  
  Docker containers are very similar to LXC containers, and they have similar security features. When you start a container with docker run, behind the scenes Docker creates a set of namespaces and control groups for the container.
  
  
  ---
  
  