[英]Docker Host on Ubuntu taking all the space on VM
Current Setup:当前设置:
Machine OS: Windows 7
Vmware: VMWare workstation 8.0.2-591240
VM: Ubuntu LTS 16.04
Docker on Ubuntu: Docker Engine Community version 19.03.5
I have setup docker containers to run bamboo agents recently.我最近设置了 docker 容器来运行竹代理。 It's keep running out of space after.
之后它的空间一直用完。 Can anyone please suggest me mounting options or any other tips to keep the volume down?
任何人都可以建议我安装选项或任何其他降低音量的技巧吗?
Ps.附言。 I had the similar setup before and it was all good until the VM got corrupted and need to setup the new VM.
我之前有过类似的设置,一切都很好,直到 VM 损坏并需要设置新的 VM。
root@ubuntu:/# df -h
Filesystem Size Used Avail Use% Mounted on
udev 5.8G 0 5.8G 0% /dev
tmpfs 1.2G 113M 1.1G 10% /run
/dev/sda1 12G 12G 0 100% /
tmpfs 5.8G 0 5.8G 0% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 5.8G 0 5.8G 0% /sys/fs/cgroup
tmpfs 1.2G 0 1.2G 0% /run/user/1000
overlay 12G 12G 0 100% /var/lib/docker/overlay2/e0e78a7d84da9c2a1e1c9f91ee16bc6515d8660e1a2db5e207504469f9e496ae/merged
overlay 12G 12G 0 100% /var/lib/docker/overlay2/8f3a73cd0b201f4a8a92ded0cfab869441edfbc2199574c225adbf78a2393129/merged
overlay 12G 12G 0 100% /var/lib/docker/overlay2/3d947960c28e834aa422b5ea16c261739d06bf22fe0f33f9e0248d233f2a84d1/merged
12G is quite a low space to be able to leverage cached images to speed up the building process. 12G 是一个相当低的空间,能够利用缓存的图像来加速构建过程。 So, assuming you don't want to expand the root partition of that VM, what you can do is clean up images after every build, or every X builds.
因此,假设您不想扩展该 VM 的根分区,您可以做的是在每次构建或每次 X 构建后清理映像。
For example, I follow the second approach, I run a cleaner job every night in my Jenkins agents to prevent the disk getting out of space.例如,我遵循第二种方法,我每天晚上在我的 Jenkins 代理中运行一个更清洁的工作,以防止磁盘空间不足。
Docker installation by default takes your /var space.默认情况下,Docker 安装会占用您的 /var 空间。 Cleaning up your unused containers will work for some time and stop yielding you when you really cant delete more.
清理您未使用的容器将工作一段时间,并在您真的无法删除更多内容时停止让您使用。 The only way is to map your data-root of your daemon to a more available disk space.
唯一的方法是将守护进程的数据根映射到更多可用的磁盘空间。 You can do the same by configuring below param,
您可以通过配置以下参数来执行相同的操作,
data-root
in your daemon.json
file. data-root
在daemon.json
文件中。
{
“data-root”: “/new/path/to/docker-data”
}
Once you have done that do a systemctl daemon-reload
to reload the configuration changes.完成后,执行
systemctl daemon-reload
以重新加载配置更改。
Doing this will make docker copy all existing container volume data to the new path.这样做将使 docker 将所有现有容器卷数据复制到新路径。 This will resolve your space issue permanently.
这将永久解决您的空间问题。
If you wish not to kill your running containers during daemon-reload you must have configured live-restore
property in your daemon.json
file.如果您不想在 daemon-reload 期间
daemon.json
正在运行的容器,您必须在daemon.json
文件中配置live-restore
属性。
Hope this helps.希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.