Docker Community Forums

Share and learn in the Docker community.

Error starting container after moving docker root directory

(Robert) #1

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

Let me know if you need more information.

(Martin Terp) #2


So how did you tell docker that you moved the data? created a symlink?
You can try and add “data-root” to your daemon.json

(Robert) #3

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://

(Martin Terp) #4

im not sure if this would work, but.

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

(Robert) #5

Thanks a lot! Making the change in that file worked perfectly :tada:
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 :confused: