As answered in this questions: Does Docker on MacOS support tmpfs? In order to run in memory docker, I need to move docker volumes to ramdisk. In macOS I can do it through docker preferences. However, I would like to write a script that could do it for me everytime I run docker on my machine. Is it possible to specify this setting using cmdline in mac?
- 7,841
- 12
- 40
- 77
- 223
- 2
- 3
2 Answers
Docker is running in a VM on MacOS. One of your options is to put the entire VM on a tmpfs. You could use this shell script to create and mount the ramdisk: https://gist.github.com/koshigoe/822455
Here is a guide for resizing the machine. https://gist.github.com/stefanfoulis/5bd226b25fa0d4baedc4803fc002829e
The trick is to stop docker first, then you can make changes and move the
~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2
wherever you like and symlink there from this location.
- 5,807
- 1
- 21
- 53
I might be misunderstanding the question.
You tell docker where to put your volume data when you run the container. See the docs. It's not something you need to define in a global config. For example:
docker run -v /Volumes/DockerData/nginx_conf:/etc/nginx/conf.d nginx:latest
The above would run nginx but pull whatever config files you have in nginx_conf.
- 166
- 2
-
okay may be I am misunderstaing it. Isnt -v is only to mount some local host directory into docker? How I can specify to run docker in ramdisk.. that's my question. In other words how to specify nginx runs in ramdisk. I know how to do it using gui but I would like to do it in cmdline – muhammad haris Apr 30 '18 at 17:12
-
You are correct. This is only for the container volumes, not the docker binary itself. – Jacob Vanus Apr 30 '18 at 17:19