简体   繁体   中英

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. 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.

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. 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.

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.

Docker installation by default takes your /var space. 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”: “/new/path/to/docker-data”
}

Once you have done that do a systemctl daemon-reload to reload the configuration changes.

Doing this will make docker copy all existing container volume data to the new path. 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.
Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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