Analysis of tmpfs mounts example of Docker data Storage
This article mainly introduces the relevant knowledge of "tmpfs mounts case Analysis of Docker data Storage". The editor shows you the operation process through the actual case. The operation method is simple, fast and practical. I hope this article "tmpfs mounts case Analysis of Docker data Storage" can help you solve the problem.
Tmpfs mounts
The volumes and bind mounts modes enable us to share files between the host and the container so that we can persist the data to the host to avoid the problem of data loss after the container is stopped when writing to the container storage layer.
If you use linux to run docker, there is another solution to avoid writing data to the container storage layer: tmpfs mounts.
Tmpfs mounts, as its name implies, is a non-persistent data store. It only stores the data in the host's memory, and once the container stops running, the tmpfs mounts will be removed, resulting in data loss.
The use of tmpfs mounts
We can use tmpfs mounts when running the container by specifying either the-- tmpfs parameter or the-- mount parameter:
$docker run-d\-it\-- name tmptest\-- mount type=tmpfs,destination=/app\ nginx:latest$ docker run-d\-it\-- name tmptest\-- tmpfs / app\ nginx:latest
You cannot specify any other options using the-- tmpfs parameter and cannot be used with swarm service.
Use the docker container inspect tmptest command, and then look at the mounts section to see:
"tmpfs": {"/ app": ""}
Tmpfs mounts optional option
An example:
Docker run-d\-it\-- name tmptest\-- mount type=tmpfs,destination=/app,tmpfs-mode=1770\ nginx:latest 's content on "tmpfs mounts instance Analysis of Docker data Storage" ends here. Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.