Changing the Directory Used by Docker

If you want to have the docker images kept in another directory, such as a mounted volume:

sudo mkdir -p /etc/systemd/system/docker.service.d
sudo nano /etc/systemd/system/docker.service.d/docker-storage.conf

Then place the following after updating “/mnt” with your target path.

# For docker after 17.06-ce:
ExecStart=/usr/bin/dockerd -H fd:// --data-root="/mnt"

Restart Docker:

sudo systemctl daemon-reload
sudo systemctl restart docker

The old Docker directory will not be used anymore so you can remove it by:

sudo rm -rf /var/lib/docker