Docker – set a custom data folder

The default docker data folder is /var/lib/docker. This can be changed to another folder with the following steps. These all need to executed as root or with sudo.

Stop Docker on your computer

service docker stop

Create a new docker daemon config

nano /etc/docker/daemon.json

Add the following text and replace /mnt/docker with the path you want to use as the docker data folder

{ 
   "data-root": "/mnt/docker"
}

Save your changes and close the file.

(Optional) If you want to move the existing data to the new folder

cp -rp /var/lib/docker/* "/mnt/docker/"

Start Docker

service docker start

Remove the old folder if everything is working

rm -rf /var/lib/docker

Leave a Reply

Your email address will not be published. Required fields are marked *

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close