Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move Docker /var/run/docker data to different directory

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

like image 994
Baily Avatar asked Jun 05 '18 19:06

Baily


People also ask

How do I move docker volume to another drive?

First stop the docker service. Then the volumes can be moved from the default location at /var/lib/docker to the new location. Next the configuration of the docker daemon is edited to point to the new location of the volumes. The next step may not be necessary, but it is a good habit to do it anyway.

How do I move the docker data directory to another location in Windows?

Step 1 - Stop Docker Desktop. Step 2 - Relocate the existing directories %USERPROFILE%\AppData\Local\Docker and C:\ProgramData\Docker to new directories. For example - move %USERPROFILE%\AppData\Local\Docker to E:\Docker\AppData and C:\ProgramData\Docker to E:\Docker\ProgramData.


1 Answers

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).

like image 154
sp0gg Avatar answered Sep 30 '22 18:09

sp0gg