This is how i did:
sudo systemctl stop docker.service
sudo systemctl stop docker.socket
2.Then I went to systemd file of docker and added the location of new directory:
sudo vim /lib/systemd/system/docker.service
We need the edit the line begins like that: ExecStart=/usr/bin/dockerd -H fd://
Edit the line by adding --data-root like :
ExecStart=/usr/bin/dockerd --data-root /mnt/new/docker -H fd:// --containerd=/run/containerd/containerd.sock
(/mnt/new/docker is the new directory I want to use in my case.)
rsync -avxP /var/lib/docker/ /mnt/new/docker
Restart the deamon:
sudo systemctl daemon-reload
Now you can restart your docker:
sudo systemctl start docker
Check if it works as expected:
docker info | grep "Docker Root Dir"