Open In App

Restoring a Docker Container

Last Updated : 30 Sep, 2021
Like Article

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

Similar Reads

Docker - Docker Container for Node.js
Node.js is an open-source, asynchronous event-driven javascript runtime that is used to run javascript applications. It is widely used for traditional websites and as API servers. At the same time, a docker container is an isolated, deployable unit that packages an application along with its dependencies, making it highly scalable and maintainable.
7 min read
How to Install Linux Packages Inside a Docker Container?
Once you understand how to pull base Docker Images from the Docker registry, you can now simply pull OS distributions such as Ubuntu, CentOS, etc directly from the Docker hub. However, the OS Image that you have pulled simply contains a raw file system without any packages installed inside it. When you work on projects inside Docker Containers, you
2 min read
Creating a Network in Docker and Connecting a Container to That Network
Networks are created so that the devices which are inside that network can connect to each other and transfer of files can take place. In docker also we can create a network and can create a container and connect to the respective network and two containers that are connected to the same network can communicate with each other. These containers can
2 min read
How to Get the IP Address of a Docker Container?
If you want multiple Docker Containers to talk to each other, they can form a Bridge Network. Each Container Network has its own Subnet mask to distribute IP addresses. The default subnet for a Docker Network is In this article, we are going to discuss the different ways you can use to know the IP address of a Docker Container. Method
2 min read
Backing up a Docker Container
If you are a Docker Developer, you would surely know how important it is to backup your Docker Container file system. If you are working on an important Docker Application, it becomes very necessary to backup all the files and folders related to it so that in case anything goes wrong, you can get back all those files. It also helps you in managing
2 min read
Running Commands Inside Docker Container
If you are working on an application inside Docker Container, you might need commands to install packages or access file system inside the Docker Container. Executing commands inside Docker Containers should be easy enough for you since you have to do it multiple times across your development phase. Docker provides you with many ways to execute com
2 min read
Creating an Alpine Docker Container
Alpine is a Linux Distribution. Docker provides you with the low sized (only 5 MB) Alpine Linux Image. The Alpine Linux Docker Image has advantages over the Ubuntu Image because of its relatively lower size and it provides almost all the functionalities that an Ubuntu Image can. In this article, we will see how to build an Alpine Linux Image. We wi
2 min read
Docker - Setting up a MongoDB Container
MongoDB is a NoSQL database that is used in many web applications nowadays to store the data in the form of objects. Where on the other side docker is also getting so popular to launch the server fast and with using less space to launch it. So docker has created the MongoDB image to launch its container. If you launch the MongoDB image in docker th
3 min read
How to Create a PHP Docker Container?
PHP is one of the widely used programming languages across several organizations mostly used for creating web architectures and back-end applications. Most of the big tech giants still rely on PHP for their back-end applications and are also increasingly adopting developer tools such as Docker. Thus, it becomes very important to learn how to access
2 min read
How to Push a Container Image to a Docker Repository?
In this article we will look into how you can push a container image to a Docker Repo. We're going to use Docker Hub as a container registry, that we're going to push our Docker image to. Follow the below steps to push container Image to Docker repository: Step 1: The first thing you need to do is make sure that you've signed up for Docker account.
2 min read