In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Before reading this article, I hope you have a preliminary understanding of Volumes, you can refer to this article:
Detailed explanation of Volumes for Docker data Storage
The data of the default container is read and written to the storage layer of the container, and the data on the container will be lost when it is deleted. Therefore, we should try our best to ensure that write operations do not 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 the following ways:
VolumesBind mountstmpfs mounts
The following figure shows these three technologies:
Bind mounts
Bind mounts mode is very similar to Volumes, except that Bind mounts mode mounts any file or folder on the host to the container, while Volumes essentially mounts an area managed by Docker service (the folder under / var/lib/docker/volumes by default) to the container.
Bind mounts is similar to Volumes in that the host file is mounted to the container through the-v or-- mount parameter. Here is an example:
When using the-- mount parameter, you need to specify type=bind:
$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-v parameter:
$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, actually reading or writing data from the host's / usr/local/web directory. So Volumes or Bind mounts can also be seen as a way for containers and hosts to share files.
If you use Bind mounts to mount the host directory to a non-empty directory in the container, the files in the non-empty directory in the container will be hidden, and the files that the container can access to this directory come from the host directory. This is also the biggest difference in behavior between Bind mounts mode and Volumes mode.
Bind mounts usage scenario
Please refer to this article: Docker data Storage Summary
Reference article
Https://docs.docker.com/storage/bind-mounts/
Summary
The above is the whole content of this article. I hope the content of this article has a certain reference and learning value for everyone's study or work. Thank you for your support. If you want to know more about it, please see the relevant links below.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.