Docker Community Forums

Share and learn in the Docker community.

All docker containers, images disappeared

Dear All,

Found out today that all my docker images, containers are all gone. Only thing I remember doing was to install the local registry and start it. But /var/lib/docker has all the docker image files, container files etc. The changes that were done to docker were:

  1. Registry configuration
  2. In docker swarm : stack deploy of applications, services deployment.

Is there way to recover from this loss ? Why was there no warning during the docker configuration of docker registry ?

Seems like docker is extremely unstable for long term persistent applications to be running continuously. Suddenly one day it could all disappear without warning. For next couple of months, I would focus of docker save / restore to make sure that I have a copy of it everywhere.

Your thoughts.

Help us to help you: what os? what docker version? What exactly did you do (as in the exact commands and if used the content of the docker-compose.yml)?

Thanks for the response. This is docker on ubuntu 18.04.5. I don’t know what I did which caused all (images, containers) of it to disappear but data was absolutely intact in /var/lib/docker directory. I couldn’t start docker at all.
But, good news is that I was able to fully recover all the lost data ( images and containers ) all back into docker.
I like the docker’s filesystem based model, so manipulating /var/lib/docker works well when bringing back docker online.
All I did was to start fresh. 1. Move the corrupted docker lib to OLD /var/lib/docker to /var/lib/docker.OLD
2. Create empty docker directory in /var/lib
3. start docker clean.
4. stop docker
5. move one directory at a time from /var/lib/docker.OLD to /var/lib/docker and see it docker starts.

It should restore normally, including volumes directory.

Glad if it works out.

Bare in mind that some folders might requite other folders to provide a dependency they need.

Great! Thanks for updating me this information. I’m also glad if it works great.