如何增加docker build的卷大小 [英] how to increase docker build's volume size

查看:105
本文介绍了如何增加docker build的卷大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Dockerfile 中执行的步骤之一需要磁盘上超过10G的空间.确实如此.但是, docker build 中的所有中间容器都是使用10G卷创建的.

One of my steps in Dockerfile requires more than 10G space on disk. It really does. However, all the intermediate containers in docker build are created with 10G volumes.

我做了什么:

  • 使用-storage-opt dm.basesize = 25G 启动 dockerd ( docker info 说:基本设备大小:26.84GB )
  • 在构建时禁用了缓存
  • 重新拉动基本图像
  • 停止docker,从docker目录中删除所有内容,然后重新启动

这不好:中间容器中的 df -h 仍显示 10G 磁盘,而其中的 docker inspect 显示"DeviceSize":"10737418240" .

It's no good: df -h in an intermediate container still shows a 10G disk, and docker inspect of it shows "DeviceSize": "10737418240".

我错过了什么?如何增加基本卷大小?

What have I missed? How do I increase the base volume size?

推荐答案

要授予容器访问更多空间的权限,我们需要注意两件事:

To grant containers access to more space, we need to take care of two things:

  1. 确保dockerd以以下代码启动:-storage-opt dm.basesize = 25G
  2. 确保增加基本尺寸后,我们会拉出图像的干净版本.
  1. Make sure that dockerd is started with: --storage-opt dm.basesize=25G
  2. Make sure that we pull a clean version of the image after increasing the basesize.

示例:

  1. 使用以下命令启动dockerd:
  1. Start dockerd with:
--storage-opt dm.basesize=25G

  • 重新启动 docker守护程序
  • 在此处检查容器大小将显示较早的10G值:

  • Restart docker daemon
  • Checking the container size here will display the older value of 10G:

    docker run -it --rm ubuntu:xenial df -h
    

  • 删除图片并重新拖动

    docker rmi ubuntu:xenial
    docker pull ubuntu:xenial
    

  • 确认已发生更改,期望值为25G:

  • Confirm changes took place with the expected value of 25G:

    docker run -it --rm ubuntu:xenial df -h
    

  • 这篇关于如何增加docker build的卷大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆