-> By default, Docker-related data such as images, containers, volumes, and networks is stored in the /var/lib/docker directory on a Linux machine.
-> To verify, run the below command.
docker info | grep 'Docker Root Dir'

-> To modify the default location, we must create a new directory for Docker on the second partition.
-> Create a new directory /dockerdata
-> Edit /etc/fstab file and add the following entry

-> Mount the partition: mount -a

-> Before making any changes, stop the docker service and docker socket.
systemctl stop docker.service
systemctl status docker.socket


-> Now, copy the data in the root directory to the new location using the command below.
rsync -aqxP /var/lib/docker/ /dockerdata
->After copying, modify the Docker service configuration. Open the docker service configuration file with vi editor
vi /lib/systemd/system/docker.service
and replace the the below line
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
with
ExecStart=/usr/bin/dockerd --data-root /dockerdata -H fd:// --containerd=/run/containerd/containerd.sock
-> Reload the configuration and start the Docker service using the command below.
systemctl daemon-reload
systemctl start docker.service
-> Verify the Docker root directory location.
