Search code examples
dockerdocker-composerestoredocker-containerdocker-image

Docker restore deleted images


Created an ubuntu docker image. (no commits, no backups) Decided to practice and delete.

But only now I realized that I can't restore the rest :) Can restore as GIT, past images by name,ID ?

  • docker run -it ubuntu ps -A
  • docker ps -a
  • docker rm $(docker ps -aq)
  • docker images
  • docker rmi ubuntu:laters
  • docker rmi $(docker images -q) #overdid it
  • docker images
  • docker ps -a

p.s. - also read that there are saves in folders /var/lib/docker/volumes/


Solution

  • To create a version of Docker images, you can store your image in Amazon ECR. If the source code is not changed, then you can rebuild the image from the Dockerfile and it will be the same.

    If there is change in the source code, and you are using version control for your code, then you can checkout to that commit and build the Docker image again.