Change Docker Data Folder Path

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.

  1. Stop docker

    systemctl stop docker
  2. Edit or create the file /etc/docker/daemon.json with the following contents. If editing, add the data-root with the path to the new location

    "data-root": "/path/to/docker/data",
  3. 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.