brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: --shm-size gives a container a bigger /dev/shm

Linux
~/tips/tip-docker-shm-size

docker run -d --shm-size=1g <image>

Raises the size of /dev/shm inside a container, for programs that need more shared memory.

Shared memory in a container is small by default, and some programs run out of it. The size is one flag away.

The Docker docs say --shm-size sets the size of /dev/shm. The format is a number plus an optional unit: b, k, m or g. Without a unit the number means bytes, and the number must be greater than 0.

docker run -d --shm-size=1g <image>

If you leave the flag out entirely, the docs say the system uses 64m. That is the baseline to compare against when an application complains about shared memory and asks for more. Other units work the same way, so --shm-size=512m is valid too.

In a Compose file the same setting is a service key:

services:
  app:
    image: <image>
    shm_size: "1gb"

You can check the result from inside the container, and it helps to run the check before and after the change so you see the new size really applies:

docker exec <container> df -h /dev/shm

The configured value in bytes is also visible from the host:

docker inspect --format '{{.HostConfig.ShmSize}}' <container>

Raise it when an application tells you to, and use the size its own documentation names. A bigger value gives the container more room, not more speed.

Further reading: Docker docs: running containers

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link