I am new to Docker and I want to run Docker with ram only storage. In other words, I do not want Docker to save anything on persistent storage. I found out that on Linux Docker supports tmpfs. Is there any such support for MacOS? I have tried setting --tmpfs flag and docker run commands run fine on mac with that flag.
Asked
Active
Viewed 5,224 times
5
-
You might find this useful if you try to make Docker run read only. https://devops.stackexchange.com/questions/3872/how-do-i-make-read-only-mount-in-docker-container-writable – Jiri Klouda Apr 30 '18 at 04:45
1 Answers
5
According to the docs tmpfs is linux only.
RAM disk
If you want "RAM only storage", you can literally use a RAM disk. ie:
diskutil erasevolume HFS+ 'DockerDisk' `hdiutil attach -nomount ram://2097152 `
Then you can point volumes at /Volumes/DockerDisk. Drop and recreate at will.
Docker will still store its VM and images on disk. See: Docker > Preferences > Disk.
Jacob Vanus
- 166
- 2
-
1Thanks for your reply can you tell me about inmemory filesystem. It looks like it does exactly what I require. https://docs.docker.com/registry/storage-drivers/inmemory/ However I dont know how to configure it. – muhammad haris Apr 30 '18 at 16:02
-
1What I describe does not require the use of any special storage drivers from docker. MacOS is handling that for you. Just use it as a standard volume. eg:
-v /Volumes/DockerDisk/foo:/etc/foo– Jacob Vanus Apr 30 '18 at 16:42 -
okay sweet I have accepted your answer. Can you tell me how I can move the volume without using GUI on mac.. or should I ask it as a new question? – muhammad haris Apr 30 '18 at 16:45
-
Might be better as its own question, just to keep the answers separate. Off hand, I'm not sure what you mean by "move the volume". – Jacob Vanus Apr 30 '18 at 16:52
-
Here is my new question: https://devops.stackexchange.com/questions/4023/macos-how-to-move-disk-image-in-command-line – muhammad haris Apr 30 '18 at 16:57
-
The "In-memory storage driver" referenced in the first comment is for registry specifically. It is not docker storage backend, but a docker registry storage backend, so irrelevant to the described problem. – alexykot Oct 12 '20 at 14:27