Docker data storage tmpfs mounts detailed explanation

Docker data storage tmpfs mounts detailed explanation

Before reading this article, I hope you have a basic understanding of Volumes and Bind mounts. For details, please refer to the following articles:

  • Docker Data Persistence Volumes
  • Docker data persistence - Bind mounts

tmpfs mounts

Volumes and Bind mounts modes enable us to share files between the host and the container so that we can persist data on the host to avoid the problem of data loss after the container is stopped due to writing to the container storage layer.

If you are running Docker on Linux, there is another solution to avoid writing data to the container storage layer: tmpfs mounts.

tmpfs mounts, as the name implies, are a type of non-persistent data storage. It only stores data in the host's memory. Once the container stops running, the tmpfs mounts will be removed, resulting in data loss.

Use of tmpfs mounts

We can use tmpfs mounts by specifying the --tmpfs parameter or --mount parameter when running the container:

$ docker run -d \
 -it \
 --name tmptest \
 --mount type=tmpfs,destination=/app \
 nginx:latest
$ docker run -d \
 -it \
 --name tmptest \
 --tmpfs /app \
 nginx:latest

The --tmpfs parameter cannot be used to specify any other options and cannot be used with Swarm Services.

Use docker container inspect tmptest command and then view Mounts section to see:

"Tmpfs": {
 "/app": ""
},

Optional tmpfs mounts

An example:

docker run -d \
 -it \
 --name tmptest \
 --mount type=tmpfs,destination=/app,tmpfs-mode=1770 \
 nginx:latest

tmpfs mounts usage scenarios

Please refer to this article: Docker Data Storage Summary

References

https://docs.docker.com/storage/tmpfs/

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links

You may also be interested in:
  • How to modify the storage location of Docker default images and containers
  • Detailed explanation of Docker's persistent storage and data sharing
  • Docker Data Storage Volumes Detailed Explanation
  • Docker storage driver introduction
  • Detailed explanation of Bind mounts for Docker data storage
  • Summary of Docker Data Storage
  • Solution to the problem of insufficient storage resource pool of Docker server

<<:  JavaScript to implement login slider verification

>>:  Detailed explanation of the standard MySQL (x64) Windows version installation process

Recommend

MySQL 8.0.24 version installation and configuration method graphic tutorial

This article records the installation and configu...

Detailed explanation of virtual DOM and diff algorithm in react

The role of virtual DOM First of all, we need to ...

Example of how to implement underline effects using Css and JS

This article mainly describes two kinds of underl...

How to directly reference vue and element-ui in html

The code looks like this: <!DOCTYPE html> &...

Detailed explanation of MySQL string concatenation function GROUP_CONCAT

In the previous article, I wrote a cross-table up...

Method for comparing the size of varchar type numbers in MySQL database

Create a test table -- --------------------------...

Vue implements a simple magnifying glass effect

This article example shares the specific code of ...

The use of textarea in html and common problems and case analysis

The textarea tag is an HTML tag that we often use....

Practical record of Vue3 combined with TypeScript project development

Table of contents Overview 1. Compositon API 1. W...

Detailed explanation of ECharts mouse event processing method

An event is an action performed by the user or th...

How to use and limit props in react

The props of the component (props is an object) F...

Vue large screen display adaptation method

This article example shares the specific code for...

Some lesser-known sorting methods in MySQL

Preface ORDER BY 字段名升序/降序, I believe that everyon...