There may be cases where you do not want to store a container’s data on the host machine, but you also don’t want to write the data into the container’s writable layer, for performance or security reasons, or if the data relates to(涉及) non-persistent(非持久性) application state. An example might be a temporary(临时) one-time password that the container’s application creates and uses as-needed(一个示例可能是容器应用程序创建和使用的临时一次性密码。).
不是持久性的保存数据,只是保存在内存中。
Choosing the –tmpfs or –mount flag
Originally(起初), the --tmpfs flag was used for standalone containers and the --mount flag was used for swarm services. However, starting with Docker 17.06, you can also use --mount with standalone containers. In general, --mount is more explicit and verbose(明确和详细). The biggest difference is that the --tmpfs flag does not support any configurable options.
Tip: New users should use the --mount syntax. Experienced users may be more familiar with the --tmpfs syntax, but are encouraged to use --mount,because research has shown it to be easier to use.
--tmpfs: Mounts a tmpfs mount without allowing you to specify any configurable options, and can only be used with standalone containers.
The examples below show both the --mount and --tmpfs syntax where possible, and --mount is presented(提出) first. Differences between --tmpfs and --mount behavior
The --tmpfs flag does not allow you to specify any configurable options.
The --tmpfs flag cannot be used with swarm services. You must use --mount.
Limitations of tmpfs containers
tmpfs mounts cannot be shared among containers.
tmpfs mounts only work on Linux containers, and not on Windows containers.