Docker Migration Container

Source: Internet
Author: User
Tags docker ps docker run

Backup, recovery, and migration of containers in Docker
1. Backup container
First, to back up the containers in Docker, we would like to look at the list of containers we want to back up. To achieve this, we need to run the Docker PS command in the Linux machine where we run the Docker engine and have created the container

# docker PS

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7D/83/wKioL1bqGFugGixBAAATp4Gvne0509.png "title=" 1.png " alt= "Wkiol1bqgfuggixbaaatp4gvne0509.png"/> after this, we want to select the container that we want to back up, and then go to create a snapshot of the container. We can use the Docker commit command to create a snapshot.

# docker Commit-p 30b8f18f20b4 Container-backup

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/7D/85/wKiom1bqGAjiw3rKAAAad3_LGqo001.png "title=" 2.png " alt= "Wkiom1bqgajiw3rkaaaad3_lgqo001.png"/>

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

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/7D/85/wKiom1bqGDCBB94hAAAWz-WisTs713.png "title=" 3.png " alt= "Wkiom1bqgdcbb94haaawz-wists713.png"/> as we can see, the snapshot above has been saved as a Docker image.

If you want to save this image on a local machine for later use, we can back it up as a tar package. To complete this operation, we need to run the following Docker Save command.

# docker Save-o ~/container-backup.tar Container-backup

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/7D/83/wKioL1bqGQ2zPb8qAAAb6GjtjiM582.png "title=" 4.png " alt= "Wkiol1bqgq2zpb8qaaab6gjtjim582.png"/>

To verify that the TAR package has been generated, we only need to run the LS command in the directory where the tar package is saved.

2. Recovering containers

If we back up the Docker image as a tar package file locally, we can load the Docker image by using the Docker Load command, followed by a backup path to the TAR package.

# docker Load-i ~/container-backup.tar

Now, to make sure that these Docker images are loaded successfully, let's run the Docker images command

< Span style= "Font-family:tahoma, Arial, ' song Body '; Font-size:14px;line-height:25.2px;background-color:rgb (255,255,255);" > # Docker images

< Span style= "Font-family:tahoma, Arial, ' song Body '; Font-size:14px;line-height:25.2px;background-color:rgb (255,255,255);" > in the mirror is loaded , we will use the loaded image to run the Docker container.

< Span style= "Font-family:tahoma, Arial, ' song Body '; Font-size:14px;line-height:25.2px;background-color:rgb (255,255,255);" > # Docker run-d-P 80:80 container-backup

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7D/86/wKiom1bqGyDho5M_AAAYPYtNibA295.png "title=" 4.png " alt= "Wkiom1bqgydho5m_aaaypytniba295.png"/>3. Migrating Docker containers
The migration container also involves the above two operations, backup and recovery. We can migrate any Docker container from one machine to another machine. During the migration process, we will first back up the container as a Docker image snapshot. If we pack the image into a tar package and back it up locally, we just need to copy or move the image onto the machine we want, load the image and run the required container.

Docker Migration Container

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.