Skip to content

Commit 005d3bc

Browse files
authored
docs: note that tmpfs usage counts toward container memory limit (#25741)
tmpfs is backed by host memory and that usage is charged to the container's memory cgroup. A large `tmpfs-size` (or a host-mounted tmpfs) does not give you RAM outside `--memory`, and filling the mount can still OOM the container. Called that out in the intro and limitations, with a pointer to the runtime metrics page. Fixes moby/moby#47967 --------- Signed-off-by: Dean Chen <862469039@qq.com>
1 parent e4b2119 commit 005d3bc

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

content/manuals/engine/storage/tmpfs.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ As opposed to volumes and bind mounts, a tmpfs mount is temporary, and only
2020
persisted in the host memory. When the container stops, the tmpfs mount is
2121
removed, and files written there won't be persisted.
2222

23+
Because tmpfs stores data in memory, that usage counts against the container's
24+
memory cgroup limit (`--memory` / Compose `mem_limit`). Setting a large
25+
`tmpfs-size` (or host-mounted tmpfs) does not give the container extra RAM
26+
outside that limit — filling the mount can still OOM the container. Memory
27+
metrics for the container include tmpfs usage; see
28+
[runtime metrics](/manuals/engine/containers/runmetrics.md).
29+
2330
tmpfs mounts are best used for cases when you do not want the data to persist
2431
either on the host machine or within the container. This may be for security
2532
reasons or to protect the performance of the container when your application
@@ -47,6 +54,8 @@ the mount.
4754

4855
- Unlike volumes and bind mounts, you can't share tmpfs mounts between containers.
4956
- This functionality is only available if you're running Docker on Linux.
57+
- Data on a tmpfs mount counts toward the container memory limit. A large
58+
`size=` value does not raise that limit.
5059
- Setting permissions on tmpfs may cause them to [reset after container restart](https://github.com/docker/for-linux/issues/138). In some cases [setting the uid/gid](https://github.com/docker/compose/issues/3425#issuecomment-423091370) can serve as a workaround.
5160

5261
## Syntax

0 commit comments

Comments
 (0)