DEV Community

loading...
Cover image for Move the Docker directory

Move the Docker directory

Romero Dias
Life is so short to write unproud code
Updated on ・1 min read

Hi folks, I hope all is well!

In this post, we going to see some steps to move the defult docker directory "/var/lib/docker" to another.
Usually doing it when the docker host disk was not propertly dimensioned and we cannot increase de size.

Stop the docker service

service docker stop

Verify if docker process is running yet

ps faux | grep docker --color

Verify there is some files in the default docker directory

ls -la /var/lib/docker/

Make a backup from docker directory

tar -zcC /var/lib docker > /dados/docker/bkp/var_lib_docker-backup-$(date +%s).tar.gz

Move the directory /var/lib/docker to new home

mv /var/lib/docker /dados/docker

Create a symlink

ln -s /dados/docker /var/lib/docker

Verify symlink working well

ls -la /var/lib/docker

Start the docker service

service docker start

Discussion (0)