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?
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.
I am actually seeing this same exact issue but in a slightly different scenario. Instead of having the entire /var/lib/docker directory symlinked, I only symlinked /var/lib/docker/overlay2 to have it mapped to a separate mount so as to minimize space consumption on my root filesystem.
So, yeah, definitely related to being symlinked. I’m doing more research but thought I’d pop in to this thread to mention this.
How about doing it properly? Edit the file /etc/docker/daemon.json and add or modfy the “data-root” entry. If you configuration is empty, the file will look like this:
{
“data-root”: “/new/data/root/path”
}
Restart the docker daemon!
source:
Warning: all images, containers and such will be unavailable, unless you move the data from /var/lib/docker to the new location. If the new location is formated with a different filesystem, it might happen that a diferent storage driver is used, which will NOT be able to read the data written by the previous storage driver.
Just wanted to add one thing: after I moved Docker directory and tried docker compose up, I got an error message: Error response from daemon: error evaluating symlinks from mount source "/var/lib/docker/volumes/dev_redis-data/_data": lstat /var/lib/docker/volumes: no such file or directory
Thankfully, there already was a thread covering this error.
After I ran
sed -i 's%/var/lib/docker%/new/dir%g' /new/dir/containers/*/config.v2.json
as described there (and for some reason I had to run it twice), Docker started working again.