Files
MarkdownNotes/howto - change default docker directory.md
2023-04-28 12:38:36 -04:00

882 B
Raw Permalink Blame History

How to move the default /var/lib/docker to another directory for Docker on Linux?

How to move the default /var/lib/docker to another directory for Docker on Linux? | DigitalOcean

  • Stop the server: sudo systemctl stop docker
  • Create/edit the configuration at /etc/docker/daemon.json, for example: { "data-root": "/new/path/docker-data-root" }
  • Copy your data there:
sudo cp -axT /var/lib/docker /new/path/docker-data-root

(if the target docker-data-root directory already exists, make sure you dont accidentally copy into a docker subdirectory).

  • Start the server:
sudo systemctl start docker
  • Check everything works:
sudo docker images