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--
Taking the jenkins container as an example, three methods are introduced here.
Method one
Package the container into an image, and the data will be in the image. Im:1.0 is the name of the container, so you can take whatever you want.
Docker commit im:1.0
Rerun the mirror, and-v map the tmp directory in the container to the tmp directory on the host
Docker run-itd-v / tmp:/tmp im:1.0 / / the first tmp is the host directory, and the second is the directory in the container
Copy the file of / var/jenkins_home to tmp. Note that the container name here is randomly generated and can be viewed through docker ps | grep im:1.0.-it is an interactive terminal.
Docker exec-it cp-r / var/jenkins_home / tmp / / cp copy and paste
Go to the tmp directory to see if there is an extra jenkins_home directory
Cd / tmpls
Enter the jenkins_home directory and move the content to the home, srv and other directories. Because the tmp directory is temporarily saved, the next linux restart will be deleted, so the data can be persisted.
Cd jenkins_home/mv
Note that after the data is backed up, delete the extra containers just generated.
Docker stop & & docker rm
Method two
Introduction of official documents
Execute the following command, for the running container name,-v mapping, / tmp/backup directory is randomly specified, cvf compression, / var/jenkins_home is the directory to be backed up
Docker run-rm-volumes-from-v / tmp/backup:/backup ubuntu tar cvf / backup/backup.tar / var/jenkins_home
Then go to the backup directory and you will see the compressed files above
Cd tmp/backup/ls
Decompression
Tar xvf backup.tar
After decompressing, there will be one more var file. When you enter it, you can see the jenkins_home directory, which is the same as the data backed up by method 1. Use the mv command to move to another directory.
Cd var/jenkins_homemv
Compared to the first method, using-- rm, we do not need to worry about resource recycling.
Method three
Before trying the third method, let's go to the tmp directory and delete the jenkins_home and backup directories
Rm-rf jenkins_home/ backup/
View Container id
Docker ps | grep jenkins_im
Copy the jenkins_home directory of the container to the current tmp directory
Docker cp: var/jenkins_home / tmp/
Enter tmp to see if there is a jenkins_home.
Cd tmp/ls
When you enter jenkins_home, you will see the same data as before, and finally the same operation will be done. Move the content to another directory.
Mv
So far, this is the end of this article on how to copy and back up docker container data. for more information about copying and backing up docker container data, please search for previous articles or continue to browse the following related articles. I hope you will support it in the future!
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.