It is possible to change docker root directory by creating a systemd drop-in service file. This is useful when you want images and containers or docker generated files to be located in another partition or drive.
Create drop-in configuration file
- Create the systemd directory:
sudo mkdir /etc/systemd/system/docker.service.d/
- Create the docker.service drop-in file:
sudo nano /etc/systemd/system/docker.service.d/docker.root.conf
- Add the following configuration :
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -g /your/custom/docker/root -H fd://