Docker Community Forums

Share and learn in the Docker community.

How to change /var/lib/docker directory with Overlay2

docker

(Reinchek) #1

Hi, as in the title, i’m trying to know how change the /var/lib/docker default installation folder with another in a different partition. This because i’ve no enough space in root partition but i still need of all installed containers. I searched on the web for this question before ask it here. Who can help me?

Good year to all. :slight_smile:


(Sam) #2

stop the docker deamon
make a link to another folder for the ‘docker’ path (/var/lib/{symlink})
start the docker daemon


(Reinchek) #3

@sdetweil thanks for reply… more simple than i was think :slight_smile:
but before links the docker folder, i’ve to move existents contents into the new directory?


(Sam) #4

yes

  • make the new folder on the other volume,
  • stop the docker daemon,
  • move everything,
  • make a symbolic link,
  • start docker daemon…

(Reinchek) #5

@sdetweil thanks! it works!

Good year. :wink:


(Ajatkj) #6

Hi, I did this but I get an error while trying to build an image from Dockerfile saying:

OCI runtime create failed: /var/lib/docker/overlay2/6b43fa390506232a0d0895db436eebaf717d630a05d40b464f24673fdbd273c9/merged is not an absolute path or is a symlink: unknown

Could this be related to creating the symlink? I remember it working fine before creating the symlink.


(Sam) #7

Did u copy everything from the original /var/lib to the new location with the same privileges?