Hi, I installed Docker CE on my machine after upgrading my OS. Before starting the daemon, I copied over the docker folder from my backup to the new disk. Previously, docker data was in /var/lib/docker, but my new disk is mounted in /srv, and moved the data to /srv/docker. The backup was on disk with the same permissions as the original, so copied all the docker folder with cp -rpv.
Containers that don’t have volumes work fine, and I’m even able to see past container executions with docker ps -a. However, when I try to start a container with a volume, I get this error:
Error response from daemon: error evaluating symlinks from mount source "/var/lib/docker/volumes/esdata/_data": lstat /var/lib/docker: no such file or directory
Error: failed to start containers: admiring_yalow
How can I fix this?
Here’s some information about my system:
$ docker version
Client:
Version: 18.09.0
API version: 1.39
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:48:47 2018
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.0
API version: 1.39 (minimum version 1.12)
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:19:08 2018
OS/Arch: linux/amd64
Experimental: false
OS: Fedora 29 x64
$ uname -a
Linux telperion 4.19.4-300.fc29.x86_64 #1 SMP Fri Nov 23 13:03:11 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
I created a systemd service override: created a file in /etc/systemd/system/docker.service and changed the ExecStart config: ExecStart=/usr/bin/dockerd -g /srv/docker -H unix://
#Get the full id of the container:
docker ps --no-trunc --format "table {{.ID}}\t{{.Names}}"
#Edit the container config (backup first)
EDITOR /srv/docker/containers/FULLID/config.v2.json
In that file, you should be able to see the path for the mounts, if they are still pointing to /var/lib/docker/vol…
You can try and change that to your new path.
Thanks a lot! Making the change in that file worked perfectly
For the record, I needed to change that file while the docker daemon was stopped, because if I changed it while it was running, the file was restored back when I tried to run the container
There are countless pages out there describing how to move your docker directory to another location. None of them mentioned @terpz tip about the config.v2.json files containing the absolute path to the original location.
Thanks for the tip, you absolutely can’t move your docker storage location without also updating these files.
Hi everyone, I am struggeling with the same issue: docker consumed a lot of space on the /var volume so I moved it to a new location (so far so good) and used the proposed commands here, to update the config.v2.json files (Thanks a lot for this convenient solution) but I am struggling with one container: Portainer.
I created it that way: docker volume create portainer_data
The sed-reccomendation fixes the path in config.v2.json but when I try to start the container (docker container star portainer) I get:
Error response from daemon: error evaluating symlinks from mount source "/var/lib/docker/volumes/portainer_data/_data": lstat /var/lib/docker: no such file or directory
and when editing config.v2.json, I see, that the changes made before are gone and there are still the old paths. What am I doing wrong or how can I fix it ?
How exactly did you do that? Did you move the data and create a symlink (i hope not!), Did you move the data and mount the new location (either by mounting a filesystem into that folder or by bind mounting a folder into that folder)? Did you change the data-rootsetting in /etc/docker/deamon.json?
copied (rsync) the old content to the new location
added data-root, pointing to the the new location in /etc/docker/daemon.json
renamed the old docker /var/lib/docker to /var/lib/docker.old
re-started docker
Then all, except for two, containers instantly started fine from the new location.
Then I used
sed -i 's%/var/lib/docker%/new/dir%g' /new/dir/containers/*/config.v2.json
to fix “orphaned” paths in the config.v2.json - files, which fixed one of the two containers issue.
But then I ended with what I described: Portainer does not want to start with the error:
Error response from daemon: error evaluating symlinks from mount source "/var/lib/docker/volumes/portainer_data/_data": lstat /var/lib/docker: no such file or directory
I then restricted the sed command, to the folder with the config.v2.json in it and checked the file manually: All wrong references were fixed.
When starting portainer however, I get the error message again and the config.v2.json contains the old links again.
It is quite odd that you modified the config.v2.json with stopped docker engine. Then started the engine and see that all changes are reverted. Just to be sure: this does only happen for the Portainer container, and not with the others?
Did you make sure the new location uses the same filesystem type the old used, and that the same storage driver is used by docker?