@@ -60,10 +60,67 @@ $ docker run --tmpfs <mount-path>
6060```
6161
6262In general, ` --mount ` is preferred. The main difference is that the ` --mount `
63- flag is more explicit and supports all the available options.
63+ flag is more explicit. On the other hand, ` --tmpfs ` is less verbose and gives
64+ you more flexibility as it lets you set more mount options.
6465
6566The ` --tmpfs ` flag cannot be used with swarm services. You must use ` --mount ` .
6667
68+ ### Options for --tmpfs
69+
70+ The ` --tmpfs ` flag consists of two fields, separated by a colon character
71+ (` : ` ).
72+
73+ ``` console
74+ $ docker run --tmpfs < mount-path> [:opts]
75+ ```
76+
77+ The first field is the container path to mount into a tmpfs. The second field
78+ is optional and lets you set mount options. Valid mount options for ` --tmpfs `
79+ include:
80+
81+ | Option | Description |
82+ | ------------ | ------------------------------------------------------------------------------------------- |
83+ | ` ro ` | Creates a read-only tmpfs mount. |
84+ | ` rw ` | Creates a read-write tmpfs mount (default behavior). |
85+ | ` nosuid ` | Prevents ` setuid ` and ` setgid ` bits from being honored during execution. |
86+ | ` suid ` | Allows ` setuid ` and ` setgid ` bits to be honored during execution (default behavior). |
87+ | ` nodev ` | Device files can be created but are not functional (access results in an error). |
88+ | ` dev ` | Device files can be created and are fully functional. |
89+ | ` exec ` | Allows the execution of executable binaries in the mounted file system. |
90+ | ` noexec ` | Does not allow the execution of executable binaries in the mounted file system. |
91+ | ` sync ` | All I/O to the file system is done synchronously. |
92+ | ` async ` | All I/O to the file system is done asynchronously (default behavior). |
93+ | ` dirsync ` | Directory updates within the file system are done synchronously. |
94+ | ` atime ` | Updates file access time each time the file is accessed. |
95+ | ` noatime ` | Does not update file access times when the file is accessed. |
96+ | ` diratime ` | Updates directory access times each time the directory is accessed. |
97+ | ` nodiratime ` | Does not update directory access times when the directory is accessed. |
98+ | ` size ` | Specifies the size of the tmpfs mount, for example, ` size=64m ` . |
99+ | ` mode ` | Specifies the file mode (permissions) for the tmpfs mount (for example, ` mode=1777 ` ). |
100+ | ` uid ` | Specifies the user ID for the owner of the tmpfs mount (for example, ` uid=1000 ` ). |
101+ | ` gid ` | Specifies the group ID for the owner of the tmpfs mount (for example, ` gid=1000 ` ). |
102+ | ` nr_inodes ` | Specifies the maximum number of inodes for the tmpfs mount (for example, ` nr_inodes=400k ` ). |
103+ | ` nr_blocks ` | Specifies the maximum number of blocks for the tmpfs mount (for example, ` nr_blocks=1024 ` ). |
104+
105+ ``` console {title="Example"}
106+ $ docker run --tmpfs /data:noexec,size=1024,mode=1777
107+ ```
108+
109+ Not all tmpfs mount features available in the Linux mount command are supported
110+ with the ` --tmpfs ` flag. If you require advanced tmpfs options or features, you
111+ may need to use a privileged container or configure the mount outside of
112+ Docker.
113+
114+ > [ !CAUTION]
115+ > Running containers with ` --privileged ` grants elevated permissions and can
116+ > expose the host system to security risks. Use this option only when
117+ > absolutely necessary and in trusted environments.
118+
119+ ``` console
120+ $ docker run --privileged -it debian sh
121+ /# mount -t tmpfs -o <options> tmpfs /data
122+ ```
123+
67124### Options for --mount
68125
69126The ` --mount ` flag consists of multiple key-value pairs, separated by commas
@@ -86,10 +143,6 @@ Valid options for `--mount type=tmpfs` include:
86143$ docker run --mount type=tmpfs,dst=/app,tmpfs-size=21474836480,tmpfs-mode=1770
87144```
88145
89- ### Options for --tmpfs
90-
91- The ` --tmpfs ` flag does not let you specify any options.
92-
93146## Use a tmpfs mount in a container
94147
95148To use a ` tmpfs ` mount in a container, use the ` --tmpfs ` flag, or use the
0 commit comments