【问题标题】:is it possible recover the deleted docker image是否可以恢复已删除的 docker 映像
【发布时间】:2022-02-18 14:21:57
【问题描述】:

我在服务器中执行 docker(Docker version 19.03.1, build 74b1e89) clean 命令:

docker system prune

令我惊讶的是,这个命令删除了停止的容器。这就是问题所在,一些容器由于某种原因停止了,但我仍然想在未来使用它。现在被删除了,是否可以恢复被误删的停止的容器?

【问题讨论】:

    标签: docker


    【解决方案1】:

    Docker 镜像和容器不一样。见this answer。

    docker system prune告诉你:

    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]
    

    因此,它删除了您的容器以及它所基于的映像(如果没有其他容器基于同一映像运行)也就不足为奇了。

    我认为无法恢复您的映像或容器,但您可以重建它们。根据图像的获取方式,您必须运行:

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

    之后,您将拥有您的图像,您可以再次运行容器:

    docker run <image>
    

    【讨论】:

      【解决方案2】:

      不,这是不可能的。你必须拉回镜像docker pull image,或者重建镜像。

      【讨论】:

        猜你喜欢
        • 2021-03-04
        • 2021-09-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-02-29
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多