skip to Main Content

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?

2

Answers


  1. No, it is not possible. You have to repull the image docker pull image, or rebuild the image.

    Login or Signup to reply.
  2. 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>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search