On a new install of Docker, it sets the data folder path to /var/lib/docker
. That’s good for most use cases however I had to setup docker on a server with an external NFS mounted storage. After trying out a few of the older methods which were too cumbersome or didn’t work, I stumbled on a newer approach that suited my needs.
Below are the instructions I used to get it to work.
Stop docker
systemctl stop docker
Edit or create the file
/etc/docker/daemon.json
with the following contents. If editing, add thedata-root
with the path to the new location{ "data-root": "/path/to/docker/data", }
Start docker
systemctl start docker
And now docker data is stored in a new location. Note that you will need to download any images perviously used as this is a new instantiation of the folder structure.
Cheers!