Summary of Docker Data Storage

Summary of Docker Data Storage

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

  • Docker Data Storage Volumes
  • Docker data storage Bind mounts
  • Docker data storage tmpfs mounts

The following figure shows the differences between Volumes, Bind mounts and tmpfs mounts:

Volumes usage scenarios

  • Share data between multiple containers.
  • There is no way to ensure that the Docker host has a specific folder or directory structure. Using Volumes can mask these host differences.
  • When you want to store your data on a remote host or cloud provider.
  • When you want to back up, restore, or migrate data from one Docker host to another, Volumes are a better choice.

Use cases for bind mounts

  • Share configuration files between the host and the container. For example, if you save the configuration file of the nginx container on the host machine and mount it through Bind mounts, you do not need to enter the container to modify the nginx configuration.
  • Share code or build output between the host and the container. For example, you can mount the target directory of a project on the host into the container. In this way, when Maven builds a new product on the host, it can be run directly in the container without generating a new image.
  • The file or directory structure on the Docker host is determined

Use cases for tmpfs mounts

  • When you do not want to persist data in the container or host for security or other reasons, you can use the tmpfs mounts mode.

Differences in behavior between bind mounts and volumes

  • If you mount an empty volume to a non-empty container directory, the files in the container directory will be copied to the volume, that is, the original files in the container directory will not be overwritten by the volume.
  • If you use Bind mounts to mount a host directory to a container directory, the original files in the container directory will be hidden, so that only the files in the host directory can be read.

References

https://docs.docker.com/storage/#good-use-cases-for-tmpfs-mounts

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
  • Docker data storage tmpfs mounts detailed explanation
  • Solution to the problem of insufficient storage resource pool of Docker server

<<:  Detailed explanation of the initial use of Promise in JavaScript asynchronous programming

>>:  The main differences between MySQL 4.1/5.0/5.1/5.5/5.6

Recommend

The implementation process of extracting oracle data to mysql database

In the migration of Oracle database to MySQL data...

HTML design pattern daily study notes

HTML Design Pattern Study Notes This week I mainl...

JavaScript canvas to achieve scratch lottery example

This article shares the specific code of JavaScri...

Detailed explanation of Vue's seven value transfer methods

1. From father to son Define the props field in t...

Teach you step by step to configure MySQL remote access

Preface When using the MySQL database, sometimes ...

MySQL login and exit command format

The command format for mysql login is: mysql -h [...

MySql learning day03: connection and query details between data tables

Primary Key: Keyword: primary key Features: canno...

Detailed explanation of docker compose usage

Table of contents Docker Compose usage scenarios ...

How to get the contents of .txt file through FileReader in JS

Table of contents JS obtains the .txt file conten...

A useful mobile scrolling plugin BetterScroll

Table of contents Make scrolling smoother BetterS...

HTML table tag tutorial (19): row tag

The attributes of the <TR> tag are used to ...

How to build gitlab on centos6

Preface The original project was placed on the pu...