docker数据存储方式(tmpfs)
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(一个示例可能是容器应用程序创建和使用的临时一次性密码。).
不是持久性的保存数据,只是保存在内存中。
http://blog.51cto.com/e/u261/themes/default/images/spacer.gif
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.
--mount: 注意没有源,只有目标
$ docker run -d \
-it \
--name tmptest \
--mount type=tmpfs,destination=/app \
nginx:latest
--tmpfs
$ docker run -d \
-it \
--name tmptest \
--tmpfs /app \
nginx:latest
docker container inspect tmptest
删除:
$ docker container stop tmptest$ Docker container rm tmptest
Specify tmpfs options
--mount才会使用,--tmpfs不能使用任何选项的
OptionDescriptiontmpfs-sizeSize of the tmpfs mount in bytes. Unlimited by default.tmpfs-modeFile mode of the tmpfs in octal. For instance, 700 or 0770. Defaults to 1777 or world-writable.
The following example sets the tmpfs-mode to 1770, so that it is not world-readable within the container.
docker run -d \
-it \
--name tmptest \
--mount type=tmpfs,destination=/app,tmpfs-mode=1770 \
nginx:latest
页:
[1]