In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "how docker containers are migrated". Friends who are interested may wish to take a look. The method introduced in this paper is simple, fast and practical. Let the editor take you to learn how docker containers are migrated.
1. Backup container
First, to back up the containers in Docker, look at the list of containers we want to back up. On the Linux machine that is running the Docker engine and the container has been created, run the docker ps command.
# docker ps
After that, select the container we want to back up, and then create a snapshot of that container. You can use the docker commit command to create a snapshot.
# docker commit-p 30b8f18f20b4 container-backup
This command generates a container snapshot as a Docker image, and we can view the Docker image by running the docker images command, as follows.
# docker images
The snapshot made above has been saved as a Docker mirror. Now, there are two options for backing up the snapshot, one is that we can log in to the Docker registry and push the image, and the other is that we can package the Docker image as a tar package backup for future use.
If we want to upload or back up the image in the Docker registry, just run the docker login command to log in to the Docker registry and push the desired image.
# docker login# docker tag a25ddfec4d2a arunpyasi/container-backup:test# docker push arunpyasi/container-backup
If you do not want to back up to the docker registry, but want to save this image on your local machine for later use, we can back it up as a tar package. To do this, you need to run the following docker save command.
# docker save-o ~ / container-backup.tar container-backup
To verify that the tar package has been generated, we just need to run the ls command in the directory where the tar package is saved.
two。 Restore the container
Next, after we have successfully backed up the Docker containers, we will now restore the containers that took snapshots of the Docker images. If we have pushed these Docker images in the registry, we just need to drag that Docker image back and run it directly.
# docker pull arunpyasi/container-backup:test
However, if we backup these Docker images locally as tar package files, we can simply use the docker load command followed by the backup path of the tar package to load the Docker image.
# docker load-I ~ / container-backup.tar
Now, to ensure that these Docker images have been loaded successfully, let's run the docker images command.
# docker images
After the image is loaded, we will use the loaded image to run the Docker container.
# docker run-d-p 80:80 container-backup
At this point, I believe you have a deeper understanding of "how docker containers are migrated". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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: 223
*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.