17

I followed the following tutorial to transfer and permanently move where docker saves data previously inside /usr/bin: https://linuxconfig.org/how-to-move-docker-s-default-var-lib-docker-to-another-directory-on-ubuntu-debian-linux

However upon restarting docker and rebuilding all containers, there seems to be activity in /var/run/docker/containerd/ which I was previously trying to work around. I was hoping to have all things docker saved in a specific directory not in /var/run along with my newly created docker directory to replace /usr/bin/docker

Note: df -h did in fact prove that I am out of space in the base directory where /usr/bin and /var/run exists. I am trying to navigate all docker items to a sub directory under /opt

How do I move all things Docker to a different directory?

(Answer) Found in documentation: https://docs.docker.com/config/daemon/systemd/#runtime-directory-and-storage-driver

Baily
  • 1,290
  • 2
  • 14
  • 35

1 Answers1

30

As described in the Docker documentation, to set the docker daemon directory to <folder>:

Create /etc/docker/daemon.json with the following contents:

{
    "data-root": "<folder>",
    "storage-driver": "overlay2"
}

Restart the docker daemon.

Note that this will not move existing docker data over to the target folder - you will need to handle that (or start from scratch).

sp0gg
  • 3,722
  • 1
  • 17
  • 20
  • This didn't work for me until I followed the docs posted by the OP, and added the line `"storage-driver": "overlay2"` Docs: https://docs.docker.com/config/daemon/systemd/#runtime-directory-and-storage-driver – user554481 Mar 01 '21 at 22:10
  • 1
    I have been using this for a long time, but I wonder, are there any benefits to it compared to just a symlink? – HUSMEN Jul 30 '21 at 18:34