How to change docker root data directory

1. Stop the docker daemon

sudo service docker stop

2. Add a configuration file to tell the docker daemon what is the location of the data directory

{ 
"graph": "/path/to/your/new/docker/root"
}
{ 
"data-root": "/path/to/your/new/docker/root"
}

3. Copy the current data directory to the new one

sudo rsync -aP /var/lib/docker/ "/path/to/your/new/docker/root"sudo cp -rp /var/lib/docker/* "/path/to/your/new/docker/root/"

4. Rename the old docker directory

sudo mv /var/lib/docker /var/lib/docker.old

5. Restart the docker daemon

sudo service docker start

6. Test

7. Clean old data.

rm -rf /var/lib/docker.old

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store