Docker - update data-root

Hi guys,

I need to move all data (container, volume ecc) of docker in a new raid5 partition.

I have followed this steps that was working fine in other system.

sudo service docker stop

Add a configuration file to tell the docker daemon what is the location of the data directory
creating new file daemon.json under the directory /etc/docker:
   "data-root": "/path/to/your/docker" 

sudo rsync -aP /var/lib/docker/ /path/to/your/new/docker

sudo mv /var/lib/docker /var/lib/docker.bkp

signal-event nethserver-docker-update

at this point I should find all the old containers already “ready”, but I can’t find it any of those… only the portainer is present.

And the docker info show me the docker root dir not changed.

# docker info | grep Root
 Docker Root Dir: /var/lib/docker

In the documentation there aren’t something that can help… can you suggest what i am missing?

Update- One bit more.

Also change the docker.service the data-root doesn’t change.

nano /lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --data-root /fabristorage
signal-event nethserver-docker-update

why not change the name of the current directory and mount the RAID5 into the same “old directory name”?

1 Like

The symlink way works. Mounting the RAID5 to /var/lib/docker as @pike suggested should work too.

See this thread for more information about the symlink method.

Thanks for suggestion.

Symlink works fine!

just some basic recap, hope that can help to someone

stop all container
sudo service docker stop
sudo rsync -aP /var/lib/docker/ /raid5example/docker
rm -fr /var/lib/docker
ln -s /raid5example/docker/ /var/lib
signal-event nethserver-docker-update

And the portainer is perfectly in sync.

1 Like

Thanks for this experience, @fabgatw