How to Restore backup and Migrate the containers in Docker
Posted By : Vishal Dogra | 17-Nov-2015
How to Restore, Backup and Migrate the containers in Docker.
Now we learn how can we take backup,restore and migrate the containers into different hosts. It is an open source platform that automates the deployment of applications with fast and easy way to pack, ship and run it under a lightweight layer of software called container. It makes the great building blocks for deploying and calling web apps, databases, and back-end services without depending on a particular stack or provider. Containers are those software layers which are created from a docker image that contains the respective linux file system and applications out of the box. If we have a docker container running in our Local and need to backup those containers for future use or wanna migrate those containers, then you can donw with the docker
Let us discuss how can backup, restore and migrate the docker containers in linux.
First we have to list the container if its is in the docker. we have to see the list of images which we want to take a backup.We have to run a command to list the images or can say that containers.
# docker ps
It will be show as :
Now select the containers which you want to take a backup and after that go for the snapshot of the container. To do this we have to use docker commit to create a snapshot.
# docker commit 51e3ff454993 container-backup
With this it will generates the snapshot of the selected container. We can list the snapshot by using docker image.
# docker images
With the help of this we can able to see on the top of the images that we have selected to create a snapshot.
If we wanna upload or backup the image in the on docker hub. We can simply run docker login command to login into the docker registry hub and then push the required image.
# docker login
# docker tag 4fbf6d28c5f7 vishald/container-backup:test
# docker push vishald/container-backup
# docker push vishald/container-backup:test
If you don't want it to upload the backup on docker hub and store it on local machine. we can do it with the tarrballs.To do this we have to run a command to create a image locally.
After storing the images you can list with the docker ps..
Now just run the image which you want.By using below command.
# docker run -d -p 80:80 container-backup
Vishal has been working as a Network Administrator. Vishal's hobbies are playing cards and listening to Sufi songs.