In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to back up docker container data". In daily operation, I believe many people have doubts about how to back up docker container data. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to back up docker container data". Next, please follow the editor to study!
How to back up docker container data? Data in docker can be stored in media similar to virtual machine disks, called data volumes (Data Volume) in Docker. Data volumes can be used to store data from Docker applications and to share data among Docker containers. The data volume is presented to the Docker container in the form of a directory that supports sharing among multiple containers, and modifications do not affect the image.
Back up the data volumes in the dbdata data volume container
Docker run-- volume-from dadata-v $(pwd): / backup-- name worker ubuntu tar cvf / backup/backup.tar.gz / dbdata
Command explanation: use the ubuntu image to create a container called worker and mount the current directory of the local machine to the / backup directory of the worker container. Then mount the data volume of the dbdata container using-volume-from, and package the / dbdata directory to the / backup directory when the container starts. At the same time, it also exists in the current directory of the machine.
Backup container data volume
$sudo docker run-- rm-- volumes-from test-v $(pwd): / backup ubuntu:14.04 tar cvf / backup/test.tar / testtar: Removing leading `/ 'from member names/test//test/b/test/d/test/c/test/a
The above command indicates:
Start a new container and mount the volume from the test container, then mount the current directory to the container as backup, and back up all the data in the test volume as test.tar. Delete the container-rm after execution, and the backup is in the current directory, called test.tar.
Note: the following / test is the directory path of the data volume (that is, the path in the container when the data volume was created)
$ls
The backup file test.tar of test volume is generated under the current directory of the host.
At this point, the study of "how to back up docker container data" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.