6

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?

1

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.

0

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.

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.