Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

is it possible recover the deleted docker image

I execute the docker(Docker version 19.03.1, build 74b1e89) clean command in the server:

docker system prune

to my surprise, this command delete the container that stopped. That’s the problem, some container stopped by some reason but I still want to use it in the furture. Now it is deleted, is it possible to recover the mistaking deleted container that stopped?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Docker images and containers are not the same. See this answer.

docker system prune tells you:

WARNING! This will remove:
  - all stopped containers
  - all networks not used by at least one container
  - all dangling images
  - all dangling build cache

Are you sure you want to continue? [y/N]

So it should be no surprise that it removed your container and possibly also the image it was based on (if no other container was running based on that same image).

I believe it is not possible to recover your image or container, however you can rebuild them. Depending on how the image was obtained you have to run:

docker pull <image> # for an image on dockerhub or other registry
docker build <arguments> # for an image based on a dockerfile

After that you will have your image and you can run a container again with:

docker run <image>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading