f10w
f10w

Reputation: 1586

Docker: How to increase the size of tmpfs volumes?

I observed that the size of the tmpfs volumes created by docker is roughly half the size of the machine's physical memory.

For example, on a machine with 22GB of RAM, I got this:

Filesystem      Size  Used Avail Use% Mounted on
overlay         970G  130G  840G  14% /
tmpfs            64M     0   64M   0% /dev
tmpfs            12G     0   12G   0% /sys/fs/cgroup
tmpfs            20G     0   20G   0% /ramdisk
/dev/sda1       970G  130G  840G  14% /etc/hosts
tmpfs            12G  180K   12G   1% /dev/shm
tmpfs            12G     0   12G   0% /proc/acpi
tmpfs            12G     0   12G   0% /proc/scsi
tmpfs            12G     0   12G   0% /sys/firmware

I would like to increase this size. Could anybody please tell me how to do that?

Thank you very much in advance for your help!

Update: Let me add some context to this question.

In my docker I have a /ramdisk volume whose size is large (here 20GB) because one of my programs needs that:

nvidia-docker run --ipc=host -h $HOSTNAME --mount type=tmpfs,destination=/ramdisk,tmpfs-mode=1770,tmpfs-size=21474836480

When running the program, at the moment its memory usage surpasses 12GB of ramdisk, it crashes (while ramdisk still has 8GB left). Note that 12GB is the size of the other tmpfs system volumes.

So, one solution I could think of is to increase the size of those other volumes, which is my question.

Upvotes: 2

Views: 8882

Answers (1)

Szczad
Szczad

Reputation: 826

As per docker docs (20GiB as per example):

docker run -d \
  -it \
  --name tmptest \
  --mount type=tmpfs,destination=/app,tmpfs-mode=1770,tmpfs-size=21474836480 \
  nginx:latest

PS: Docs specify that by default tmpfs volumes have unlimited size, so the calculations here might be rounded down to the amount of free memory in the host OS.

SRC: https://docs.docker.com/storage/tmpfs/#specify-tmpfs-options

Upvotes: 2

Related Questions