/var/lib/docker
, which will be an issue if you have /var
on its own (usually small) partition.
After using Docker for a while you may start to run out of space on the /var partition, at which point you’ll need to either add more space to that partition or relocate it to somewhere with more space.
Here are the steps to change the directory even after you’ve created Docker containers etc.
Note, you don’t need to edit docker.service
or init.d files, as it will read the change from the .json
file mentioned below.
/etc/docker/daemon.json
(if it doesn’t exist, create it){
"data-root": "/new/path/to/docker-data"
}
sudo systemctl stop docker
ps aux | grep -i docker | grep -v grep
screen
if you have a large amount of data or unreliable ssh connection.
sudo rsync -axPS /var/lib/docker/ /new/path/to/docker-data
Options explanation, check out the man page for more info
-a, --archive archive mode; equals -rlptgoD (no -H,-A,-X)
-x, --one-file-system don't cross filesystem boundaries
-P show progress during transfer
-S, --sparse handle sparse files efficiently
sudo systemctl start docker
docker info | grep 'Docker Root Dir'
docker ps
Leave both copies on the server for a few days to make sure no issues arise, then feel free to delete it.
sudo rm -r /var/lib/docker
Official docs https://docs.docker.com/engine/admin/systemd/
Docker GitHub issue item https://github.com/docker/docker/issues/3127
Blog post inspired by linuxconfig
Tested and working on Debian Stretch (9.3) with Docker Docker version 17.12.0-ce
]]>