How about doing it properly? Edit the file /etc/docker/daemon.json
and add or modfy the “data-root” entry. If you configuration is empty, the file will look like this:
{
“data-root”: “/new/data/root/path”
}
Restart the docker daemon!
source:
Warning: all images, containers and such will be unavailable, unless you move the data from /var/lib/docker to the new location. If the new location is formated with a different filesystem, it might happen that a diferent storage driver is used, which will NOT be able to read the data written by the previous storage driver.