Skip to content
Related Articles

Related Articles

Restoring a Docker Container

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 30 Sep, 2021

If you have a backup of your Docker Container stored as a Tar File in your local machine or pushed it on the Docker Hub account, you can restore that Tar File back into a Docker Image, create a Container and use it. In this article, we are going to discuss how to restore a Docker Image from a Tar File or pulling it from your private Docker Hub account.

You can follow these steps to restore a Docker Container:

Step 1: Load the Tar File

If you have a Tar file of a Docker Image as a previous backup, you can load it using the following command. In this example, we have a Tar File called my-backup in the home directory which is the backup of an Ubuntu Image with a text file inside it.

sudo docker load -i ~/my-backup.tar

Tar File

Tar File

Docker Load Command

Docker Load Command

Step 2: Verify the Docker Image

After you have loaded the Tar File, you can verify if the Image has been added to your local repository using the following command.

sudo docker images
Verifying Image

Verifying Image

Step 3 (Optional): Pull a backed up Image from Docker Registry

If you have a backed-up Image that you pushed it earlier into your private Docker Hub account, you can pull it back using the following command.

sudo docker pull my-backup:latest

Step 4: Run the Restored Docker Container

To run the Container associated with the restored image, you can use the Docker Run command. Using the ls command, you will find the files intact inside the Docker Container.

sudo docker run -it my-backup:latest
Running Container

Running Container

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!