Sometimes the code is lost and you need to recover the required code from the image running in the container. At this time, you only need to perform a few simple operations on the server running the container to extract the code used when packaging the image. View all containers:docker container ls -a Enter the specified container according to the container ID:docker exec -ti id /bin/bash Copy the directory in the container to the service-specified folder:docker container cp id:/usr/local/tomcat/webapps/province-admin /home/test/province-admin After the above 3 steps, the code in the container has been extracted to the specified directory of the server. You can view the required code by downloading the code from the server to the local computer. Supplement: Docker data volume container backup and recovery are super detailed! Xiaobai can do it too! ! ! In daily life, we map the directory between the container and the local physical machine and store it directly locally. Then we only need to back up the local hard disk regularly. But if there is no such mapping, how should we handle backup and recovery? First we create a data volume that needs to be backed up. docker run -itd -v /opt/zz --name c1 centos /bin/bash
To verify the backup function of the data volume container, create a c11 file in the mounted /opt/zz directory and write the content "woda". [root@160e0646396d zz]# touch c11.txt [root@160e0646396d zz]# echo "woda" > c11.txt [root@160e0646396d zz]# cat c11.txt woda Then, to back up the volume container, use --volumes-from to mark the volume to be backed up and mount the current directory from the host to the container's /v3 directory. $(pwd) is a method supported by docker to specify the current directory. Those who understand the basic commands of linux will find that the pwd command is used to view the current directory in linux. After the container is started, the c23.tar file generated in the current directory is the backup file of the /opt/zz container volume. In this way, the data in the data volume container is backed up. The whole practice process is as follows: [root@client ~]# docker run --volumes-from c1 -v $(pwd):/v3 centos tar cvf /v3/c23.tar /opt/zz tar: Removing leading `/' from member names /opt/zz/ /opt/zz/c11.txt Finally, we can see the contents of the data volume of the container that we need to back up, /opt/zz/c11.txt
Second recoveryThe ultimate purpose of backup is to be able to recover, otherwise the backup is meaningless. Docker backup recovery is also very simple, only two steps are required. First, create a container /opt/x2 with an empty data volume. docker run -itd -v /opt/x2 --name c3 centos /bin/bash docker run -itd -v /opt/x2 --name c3 centos /bin/bash Then, create another container, mount the data volume in the data1 container volume, and use untar to decompress the backup file into the mounted container volume. docker run --volumes-from c3 -v $(pwd):/v3 centos tar xvf /v3/c23.tar At this time, the data of the previously backed up data volume container has been restored to the container /opt/x2. In order to view and verify the recovered data, we can start another container and mount the /opt/x2 container volume to view it. The whole practice process is as follows: [root@client ~]# docker run --volumes-from c3 -v $(pwd):/v3 centos tar xvf /v3/c23.tar opt/zz/ opt/zz/c11.txt Finally, we can see that the c11.txt we backed up earlier has now been restored to the data volume in the c3 container. The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. If there are any mistakes or incomplete considerations, please feel free to correct me. You may also be interested in:
|
<<: Detailed description of mysql replace into usage
>>: Example code for CSS to achieve horizontal lines on both sides of the text
Table of contents 1. Introduction 2. Use 1. Diffe...
1. Import echart in HTML file <!-- Import echa...
1. Docker installation and settings #Install Cent...
Table of contents Preface Stored Procedure: 1. Cr...
Before I start, let me emphasize that process.env...
1. Cause The official cerbot is too annoying. It ...
1. Introduction People who are not used to Englis...
The first cutter in China github.com/chokcoco Fir...
introduction As usual, let's start with a sce...
All prerequisites require root permissions 1. End...
Preface We all know that in Linux, "everythi...
This article example shares the specific code of ...
VC6.0 is indeed too old VC6.0 is a development to...
Compared with other large databases such as Oracl...
Since the entire application needs to be deployed...