I recently had a case where the /
partition was running very low on disk space, but I also had an additional disk mounted at /home/
with plenty of disk space.
However as by default Docker stores everything at /var/lib/docker
my /
partition was nearly full.
To fix that I moved the default /var/lib/docker
to another directory on the /home
partition.
In case that you are in the same situation, here is how to do that on a Linux server!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Before you get started, make sure to backup your Droplet so that in case that anything goes wrong, you could revert back to a backup!
Once you have your backup in place, follow these steps here:
SSH to your server
Make sure that Docker is stopped:
After that, make sure that Docker is not running with the following commands:
If you see that Docker is not running, then you could proceed. Another way of checking if there are any Docker processes is by using the
ps
command:/var/lib/docker/
Docker directory to the new location. Let’s say that we want to put the files in a folder called/home/docker
. To do so, first create the folder:Then using the
rsync
command transfer the files over:Find the following line:
And change it to:
Then reload the systemd daemons:
And finally, start Docker:
Finally, to confirm if your images are being loaded from the new path, you can inspect one of your images:
Find an image id:
Inspect the image and look for the WorkDir:
I hope that this helps! Regards, Bobby
/etc/docker/daemon.json
, for example:(if the target
docker-data-root
directory already exists, make sure you don’t accidentally copy into adocker
subdirectory).The previous answer:
-g
. Instead you should use the option documented indockerd --help
, which is--data-root
.