Restoring a Docker Container
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
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
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
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses
are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!