In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "the creation and use of docker data volumes". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. Host directory mapping container directory
[root@docker03 / opt] # docker run-d-p 80:80-v / opt:/usr/share/nginx/html nginx:latest
11414881669cfd9f9c485668233a14fb6765835df1375f4808ced1c7391d76e3
two。 Write only the container directory and create new volumes (for container data persistence)
Question: the host directory and the container directory are synchronized in real time. For example, if the container directory file is deleted, the host will also be deleted. How to achieve persistence?
[root@docker03 / opt] # docker run-d-p 81:80-v / usr/share/nginx/html nginx:latest 8a5c405a8cffe8498e3bcc59fa99f7acd4d59ffa719507687806e1e3f764438f [root@docker03 / opt] # docker volume ls (View volumes) DRIVER VOLUME NAMElocal 3f8486a2c10268789478e87c0465f8f625a70e5526ebad829798fd438d2694f6
3. Specify the name of the volume
[root@docker03 / opt] # docker run-d-p 83:80-v ashuai:/usr/share/nginx/html nginx:latest 39ebc8852f8d71f071d348964b109e3dd4c2e78a7255cbd17aff670cdf3ea14d [root@docker03 / opt] # docker volume lsDRIVER VOLUME NAMElocal 3f8486a2c10268789478e87c0465f8f625a70e5526ebad829798fd438d2694f6local ashuai
4. View the properties of the corresponding volume
[root@docker03 / opt] # docker volume inspect ashuai [{"CreatedAt": "2019-12-12T17:18:18+08:00", # creation date "Driver": "local", "Labels": null, "Mountpoint": "/ var/lib/docker/volumes/ashuai/_data", # mount point corresponding to host "Name": "ashuai" # Volume name "Options": null, "Scope": "local"}]
5. Different containers mount the same host directory
[root@docker03] # docker run-d-p 84:80-- volumes-from 11414881669c nginx:latest
58cd0ba3902748af4546c1bfefacb3837e4764e763c6bc7562b9e6d6a6bd5fac
This is the end of the content of "the creation and use of docker data volumes". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.