Docker D2 – Assignment2 – What is tempfs in docker volume and how it use it?

Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

What is tmpfs ?

Assign memory from host’s RAM to the container which is normally outside of the write-able memory that the container gets when its created and run.

This memory will eventually get removed once container lifecyle ends

How to create tmpfs ?

Command to mount on /app in container with permission of 1770

 docker run -itd --name test-tempfs --mount type=tmpfs,destination=/app,tmpfs-mode=1770 ubuntu

As we can see the filesystem for /app is created. Also notice this path /app doesn’t exist usually in a default ubuntu container

[root@ip-172-31-17-58 test-volume-bkp]# docker exec 7ed0760e1de5 df -kh
Filesystem      Size  Used Avail Use% Mounted on
overlay         100G  6.7G   94G   7% /
tmpfs            64M     0   64M   0% /dev
tmpfs           7.8G     0  7.8G   0% /sys/fs/cgroup
shm              64M     0   64M   0% /dev/shm
tmpfs           7.8G     0  7.8G   0% /app
/dev/xvda1      100G  6.7G   94G   7% /etc/hosts
tmpfs           7.8G     0  7.8G   0% /proc/acpi
tmpfs           7.8G     0  7.8G   0% /proc/scsi
tmpfs           7.8G     0  7.8G   0% /sys/firmware