Define size for /dev/shm on container engine

25,084

Mounting an emptyDir to /dev/shm and setting the medium to Memory did the trick!

spec:
  volumes:
  - name: dshm
    emptyDir:
      medium: Memory
  containers:
  - image: gcr.io/project/image
    volumeMounts:
      - mountPath: /dev/shm
        name: dshm
Share:
25,084

Related videos on Youtube

posit labs
Author by

posit labs

I make internet.

Updated on July 09, 2022

Comments

  • posit labs
    posit labs almost 2 years

    I'm running Chrome with xvfb on Debian 8. It works until I open a tab and try to load content. The process dies silently...

    Fortunately, I have gotten it to run smoothly on my local docker using docker run --shm-size=1G.

    There is a known bug in Chrome that causes it to crash when /dev/shm is too small.

    I am deploying to Container engine, and inspecting the OS specs. The host OS has a solid 7G mounted to /dev/shm, but the actual container is only allocated 64M. Chrome crashes.

    How can I set the size of /dev/shm when using kubectl to deploy to container engine?

  • Nutritioustim
    Nutritioustim over 6 years
    I'm having a similar issue, but with docker swarm. I don't see spec: or containers: entries in the docker-compose reference. How does this map to the volumes spec?
  • posit labs
    posit labs over 6 years
    Please re-read the question. I already use --shm-size to run locally. This is a question about kubectl configuration
  • posit labs
    posit labs over 6 years
    I recommend posting a new question that is specific to docker swarm
  • welch
    welch about 6 years
    Thank you!!! One truly cannot configure options to the docker launch in the kube config (and the devs are consistently obtuse about not understanding the need for this). Your config has our docker-ized selenium test no longer randomly crashing.
  • WeiChing 林煒清
    WeiChing 林煒清 almost 6 years
    but where to constrains the size of emptyDir?
  • Mitar
    Mitar almost 6 years
    Size limit is being worked on here: github.com/kubernetes/kubernetes/pull/63641
  • bu11d0zer
    bu11d0zer about 5 years
    Be aware that sizeLimit on the emptyDir will result in pod evictions if the limit is exceeded. This is much worse behavior than memory-hungry apps crashing.
  • EnriqueH
    EnriqueH over 3 years
    It worked for me on a Kubernetes (AWS EKS) cluster. Thanks SO MUCH