In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
A background
In the process of actual use, we may often encounter the situation of data sharing between containers, how to deal with it? With some options in the docker command, we can complete the data sharing between containers.
2 Lab step 2.1 create a container
Container 1: gysl-1
[root@dev] # docker run-it-- rm-- name gysl-1-v / data-1 alpine
Container 2: gysl-2
[root@dev ~] # docker run-it-- rm-- volumes-from gysl-1-- name gysl-2 alpine2.2 verifies data sharing
Create a file in the container gysl-1: gysl-1.txt
/ # cd data-1//data-1 # touch gysl-1.txt
Create a file in the container gysl-2: gysl-2.txt
/ # cd data-1//data-1 # touch gysl-2.txt
View it in two containers:
/ data-1 # ls-lhtotal 0 RWMurray Rafael-1 root root 0 Jan 10 18:45 gysl-1.txt-rw-r--r-- 1 root root 0 Jan 10 18:47 gysl-2.txt
The contents in the data-1 directory of the two containers are exactly the same.
Three summaries
3.1 when the volume of a container is shared by other containers, there is no need for other containers to create a shared directory, and the shared directory will be automatically created in other containers, which is the same as the directory name of the shared container.
3.2 the volume of a container can be shared by multiple containers at the same time.
When the container is deleted, the volume will not be deleted automatically. If the data will not be used again, you can delete the obsolete volume manually, as follows:
[root@dev ~] # docker volume lsDRIVER VOLUME NAMElocal 8126b3ad828a9a7e29ec04f4d7a1901be5e40ca6157fde62dca3421322e5de7alocal bf80e1eb66685161cb6bf6943079de4a68a7bc3db3bba241347ed051fe59fc46 [root@dev ~] # docker volume pruneWARNING! This will remove all volumes not used by at least one container.Are you sure you want to continue? [y/N] yTotal reclaimed space: 0 B
You can also:
Docker volume rm volume_name
You can also (force the deletion of volume while deleting the container):
Docker rm-vf container_name
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.