The /var/lib/docker folder is getting massive, whats the best way of move it to another partition?


My server was failing due to having the root directory completely filled. I couldnt do anything due to this (Like clean APT, or purge docker… just a bunch of errors).

So this was a hard failure and i dont want this to repeat, i ended up forcefully blowing /etc/docker to get control of my server again (Probably a lame method but i was tired).

As im running docker in a VM with low disk space and SSD, i think the best course of action would be to place the /var/lib/docker in another bigger partition of my HDDs


1.- Its this a good idea?, it wont give more issues? 2.- If so, whats its the best method to accomplish this?. Preferably a clean and simple one so i can easily repeat in new deployments.

For reference, i found people recommending changing the systemd configuration of docker. Others talk about changing the docker configuration itself, so im kind of lost about what would be better:


  • Running my containers by dockercompose

  • VM Has 10GB of root space, seems difficult to increase the partition size under Proxmox.

Thanks a lot for any advice!

EDIT: My Solution

After a lot of reading and help from everyone, i can resume the solutions to 3:

1.- Change the SystemD config: Looks good, but it wont be the more universal solution as not all distribution use systemd. Also, i preffer to leave this type of configurations on the app itself, instead of moving general configuration of the OS.

2.- Trick Docker mounting /var/lib/docker in another place, using symlinks / mountpoints: Not a bad solution, but its not that elegant or clean. As /u/bitbash mentions, the symlinks could not be our best option.

3.- Config Docker itself: Update the main config file of docker with your settings (/etc/docker/daemon.json). This was my selected option as its cleaner (Dont have to mess with the filesystem of the main OS) and can easily redeploy if needed. I found an excellent guide in this blog: Blog

Thanks everyone!

submitted by /u/thinkyougotmewrong
[link] [comments]
Source: Reddit