Before reading this article, I hope you have a preliminary understanding of Volumes. For details, please refer to this article: Docker Data Storage Volumes Detailed Explanation By default, the reading and writing of container data occurs at the container's storage layer. When the container is deleted, the data on it will be lost. Therefore, we should try to ensure that no write operations occur in the container storage layer. In order to achieve persistent storage of data, we need to choose a solution to save data. Currently, there are several ways:
The following diagram illustrates these three techniques: Bind mounts The Bind mounts mode is very similar to Volumes. The difference is that the Bind mounts mode mounts any file or folder on the host to the container, while Volumes essentially mounts an area managed by the Docker service (the default is a folder under /var/lib/docker/volumes) to the container. The use of bind mounts is similar to that of volumes, and the host files are mounted in the container through When using the $ docker run -d \ --name=nginxtest \ --mount type=bind,source=/usr/local/web,destination=/usr/share/nginx/html \ nginx:latest The above example mounts the /usr/local/web folder on the host to the /usr/share/nginx/html folder in the container. Or use the $ docker run -d \ --name=nginxtest \ -v /usr/local/web:/usr/share/nginx/html \ nginx:latest After the mount is successful, the container reads or writes data from the /usr/share/nginx/html directory, which actually reads or writes data from the /usr/local/web directory of the host. Therefore, Volumes or Bind mounts can also be seen as a way for containers and hosts to share files.
Bind mounts usage scenarios Please refer to this article: Docker Data Storage Summary References https://docs.docker.com/storage/bind-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:
|
<<: Detailed explanation of JDBC database link and related method encapsulation
>>: JavaScript to implement login slider verification
First download JDK. Here we use jdk-8u181-linux-x...
Table of contents 1: Build webpack 2. Data hijack...
Solution 1: Use conditional import in HTML docume...
This article mainly summarizes various problems o...
Table of contents Achieve results Introduction to...
Summarize This article ends here. I hope it can b...
Preface As one of the best web servers in the wor...
Overview MySQL also has its own event scheduler, ...
Table of contents 1:mysql execution process 1.1: ...
The TextBox with the ReadOnly attribute will be di...
background As the company's sub-projects incr...
The ECS cloud server created by the historical Li...
Table of contents 1. Preparation 2. Writing comma...
Although Mac systems come with PHP and Apache, so...
Setting min-width and max-width properties in tab...