Restore deleted container docker Restore deleted container docker docker docker

Restore deleted container docker


If it's just stopped, rather than removed, you should be able to find it under docker ps -a and just run docker start CONTAINER.

Unless the database was removed with docker rm -v CONTAINER, the database files are probably still in a directory somewhere under /var/lib/docker/vfs/dir/, but you may have a hard time figuring out which one. If you do manage to figure out the correct directory, you should be able to restore the db by just mounting the directory into a new database instance.


The accepted answer is correct, however I would like to add the specific steps to restore an app (in my case it was a PostgreSQL database) via its docker volume.

I am using Docker version 18.09.0, build 4d60db4 in CentOS.

  1. Go to /var/lib/docker/volumes/.
  2. In this folder, there are folders which are named as container IDs. Each container ID folder has a _data folder that contains the application files for that container. Find the specific volume you wish to restore and save its container ID somewhere to remember it in the next steps.
  3. Run the command docker volume ls to make sure that container ID is listed as volume. That will be our volume_name to restore.
  4. If you don't remember the default mount destination, run a dummy container via the command docker run -d --name postgres -p 5432:5432 postgres.
  5. Run the command docker inspect postgres
  6. Find the Mounts section and check the Destination. In my case it was /lib/postgresql/data.
  7. Stop and remove the dummy container you just started.
  8. Run the command docker run -d --name postgres -p 5432:5432 --mount source=volume_name,target=/var/lib/postgresql/data postgres
  9. At this point a container that contains the old data will be available.