简体   繁体   English

如何恢复停止空间的停靠的docker容器?

[英]How to recover a stopped docker container which ran out of space?

I've got a docker container that reached the default 10GB limit, and now I cannot start it anymore. 我有一个达到默认10GB限制的docker容器,现在我再也无法启动了它。 This is the error I receive: 这是我收到的错误:

Error response from daemon: Cannot start container dfc: setup mount namespace can't create pivot_root dir , error mkdir /var/lib/docker/devicemapper/mnt/dfc2df0ba006762d44e13a3fe12b113a970ca7d91a530a8af1e82178d22f5608/rootfs/.pivot_root753727542: no space left on device 2015/01/12 15:32:58 Error: failed to start one or more containers 来自守护进程的错误响应:无法启动容器dfc:setup mount命名空间无法创建pivot_root目录,错误mkdir /var/lib/docker/devicemapper/mnt/dfc2df0ba006762d44e13a3fe12b113a970ca7d91a530a8af1e82178d22f5608/rootfs/.pivot_root753727542:设备上没有剩余空间2015/01/12 15:32:58错误:无法启动一个或多个容器

There's a blog post explaining how to increase the size of the container past the 10GB limit, but it seens to assume the container is running. 有一篇博客文章解释了如何增加容器的大小超过10GB的限制,但它可以假设容器正在运行。 In my case, It's stopped and I can't find the correct device in /dev/mapper. 在我的情况下,它已停止,我在/ dev / mapper中找不到正确的设备。

Is there any way to increase the container size, so I can recover access to my container? 有没有办法增加容器大小,所以我可以恢复对我的容器的访问?

It is not trivial but possible. 这不是微不足道的,而是可能的。 I did it once on RedHat7. 我在RedHat7上做了一次。 It will probably not work with older versions of Centos/Redhat. 它可能不适用于较旧版本的Centos / Redhat。

I explained it in this post . 我在这篇文章中解释过。

Basically, you perform these steps: 基本上,您执行以下步骤:

  • Save the container as an image, using docker commit 使用docker commit将容器保存为图像
  • Save the new image as a tar file on disk, using docker save 使用docker save将新映像另存为磁盘上的tar文件
  • Reconfigure the default space per container, as explained in this post 重新配置每个容器的默认空间,在此解释
  • In the previous step will loose all local images and containers, but you have saved your image as a tar file on disk. 在上一步中将丢失所有本地映像和容器,但您已将映像保存为磁盘上的tar文件。
  • Load the image you previousley saved, using docker load 使用docker load加载之前保存的图像
  • Run a new container from the just loaded image, using docker run 使用docker run从刚加载的映像运行新容器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM