1

All my docker related folders are saved in /var/lib/docker. But my / space is very limited. Hence, I would like all of the content present inside this location to go to say /home/User/my_space. How would I do that? I could use symbolic link. But, that will only move the current contents of the location. I would like to move the future changes of the docker also. Please help me :)

1

Symlink is an universal solution which works, I've successfully used it plenty of times. I do not recommend using the path you suggested, though, since the files should be owned by either the root or docker users, depending on your distro/OS. Therefore, if you want to use the /home partition, then:

  • shut down docker
  • mv /var/lib/docker /home/
  • ln -s /home/docker /var/lib/docker
  • start docker

This will usually persist through upgrades unless you uninstall and reinstall Docker.

Now, more recent versions of Docker support an option in /etc/docker/daemon.json, namely the data-root option. So just edit the file and add

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

You can find the whole schema for the file in the docs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.