Pass --shm-size argument when creating VM

449 views
Skip to first unread message

Joseph Amigo

unread,
Mar 3, 2021, 9:32:31 AM3/3/21
to gce-discussion

I would like to start a VM on google cloud console with more memory in /dev/shm. Thing is the only way I've figured out how to do this is by passing somewhere the argument --shm-size to the docker run command. But I don't know where to do this when creating a VM instance with a specific docker image on Google Cloud Console. Any ideas ? Would it be possible to resize /dev/shm when while running the container ?


Fady (Google Cloud Platform)

unread,
Mar 3, 2021, 5:02:23 PM3/3/21
to gce-discussion
My understanding here is that you would like to increase memory in /dev/shm in the container. As you stated and per this Stackoverflow post, it is possible if you run the docker command and after you build and SSH to the VM instance. Now, if you are looking to automate it while creating the VM, and assuming you are using a container optimized image (COS) for a single container, you may try passing the argument to an entrypoint command or an environment variable. My understanding of the Stackoverflow post is that running the command is not the best way as the container might restart and you lose this config. Hence, another method even when using other operating systems is to use startup scripts to automate installing docker packages and maybe using docker compose to build the container with the desired  "shm_size"  and per the same Stackoverflow post.

However, if your end objective is to mount an empty tmpfs (RAM-backed filesystem), maybe using this method would better serve your use-case. 



Reply all
Reply to author
Forward
0 new messages