Docker Directory Move

Hi Guys,

I have been struggling from past weeks to find solution to my problem.

I have docker with Portainer installed on Linux mint OS and eventually i ran out of space so i have moved the docker to my external hard drive under a folder called docker.

Steps I have taken to move docker directly.

  1. edited the docker service and added the new path in it, it looks like this now >> (ExecStart=/usr/bin/docker daemon -g /media/data/docker -H fd:// --containerd=/run/containerd/containerd.sock)

  2. create new file daemon.json in etc/docker with below in it
    {
    “data-root”: “/media/data/docker”,
    “storage-driver”: “overlay2”
    }

  3. moved all docker file from old to new location via a commond which looked like this >>( rsync -aqxP /var/lib/docker/ /media/data/docker

  4. Restarted the server.

but when i do sudo systemctl status docker i get below.

● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: activating (start) since Sun 2021-06-20 12:21:46 CEST; 1h 10min ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 836 (docker)
Tasks: 8
Memory: 79.1M
CGroup: /system.slice/docker.service
└─836 /usr/bin/docker daemon -g /media/data/docker -H fd:// --containerd=/run/containerd/conta>

Jun 20 12:21:46 linuxmint systemd[1]: Starting Docker Application Container Engine…
Jun 20 12:21:47 linuxmint docker[836]: WARNING: Error loading config file: .dockercfg: $HOME is not defined

External drive is NTFS and docker folder has root permissions.

However i ignored the warring and fired up my portainer but it does not work. site unreachable.

some one help me here ?

Thank you.

The magic required to make overlay2 work, does not work with a NTFS filesystem.
Format it as Ext4 or XFS and you should be good to go.

Also, the setting in /etc/docker/deamon.json are enough, no need to alter the service defintion.

Hi, so i tried, formatted my external drive and made it ext4 and then i uninstalled docker and portainer.

Did a fresh of Install again of docker and poratiner. worked fine in the default location.

Created the /etc/docker/deamon.json with new directory and move all the folders from /var/lib/docker/ to /media/data/docker

deleted old directory /var/lib/docker/ then restarted the pc checked the docker status, which seems to be working.
sysadmin@linuxmint:~$ systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset>
Active: active (running) since Mon 2021-06-21 17:01:41 CEST; 16min ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 840 (dockerd)
Tasks: 10
Memory: 130.6M
CGroup: /system.slice/docker.service
└─840 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/conta>

Jun 21 17:01:40 linuxmint dockerd[840]: time="2021-06-21T17:01:40.106538682+02:>
Jun 21 17:01:40 linuxmint dockerd[840]: time="2021-06-21T17:01:40.106568065+02:>
Jun 21 17:01:40 linuxmint dockerd[840]: time="2021-06-21T17:01:40.106594358+02:>
Jun 21 17:01:40 linuxmint dockerd[840]: time="2021-06-21T17:01:40.107490631+02:>
Jun 21 17:01:41 linuxmint dockerd[840]: time="2021-06-21T17:01:41.027352437+02:>
Jun 21 17:01:41 linuxmint dockerd[840]: time="2021-06-21T17:01:41.291736776+02:>
Jun 21 17:01:41 linuxmint dockerd[840]: time="2021-06-21T17:01:41.430565194+02:>
Jun 21 17:01:41 linuxmint dockerd[840]: time="2021-06-21T17:01:41.432094073+02:>
Jun 21 17:01:41 linuxmint systemd[1]: Started Docker Application Container Engi>
Jun 21 17:01:41 linuxmint dockerd[840]: time="2021-06-21T17:01:41.630069346+02:>

then opened the browser and went to the 0.0.0.0:9000 (portainer address) it says site unreachable.

seems some where just one last step is going wrong, but dont know where.

Just to be sure: you did stop the docker engine before moving the files, right? Otherwise you might have created an inconsistent copy of the data-root folder.

Hi, I was not sure if I stopped the engine service so again from the beginning uninstalled and installed the docker and portainer.

Then i stopped the service with this command : sudo systemctl stop docker
To verify the service is stopped in used this command : sudo ps aux | grep -i docker | grep -v grep
then Created file /etc/docker/daemon.json
then moved the directoy using this commond : sudo rsync -aP /var/lib/docker/ /media/data/docker
then deleted the docker folder from /var/lib/docker/
at last started the service using this commond: sudo systemctl start docker
then i did sudo systemctl status docker root@linuxmint:/# sudo systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2021-06-21 22:46:30 CEST; 9min ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 907 (dockerd)
Tasks: 9
Memory: 130.4M
CGroup: /system.slice/docker.service
└─907 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Jun 21 22:46:29 linuxmint dockerd[907]: time=“2021-06-21T22:46:29.526633801+02:00” level=warning msg="Your kernel does not support CPU realtime sche>
Jun 21 22:46:29 linuxmint dockerd[907]: time=“2021-06-21T22:46:29.526948623+02:00” level=warning msg="Your kernel does not support cgroup blkio weig>
Jun 21 22:46:29 linuxmint dockerd[907]: time=“2021-06-21T22:46:29.527237114+02:00” level=warning msg="Your kernel does not support cgroup blkio weig>
Jun 21 22:46:29 linuxmint dockerd[907]: time=“2021-06-21T22:46:29.528186068+02:00” level=info msg=“Loading containers: start.”
Jun 21 22:46:30 linuxmint dockerd[907]: time=“2021-06-21T22:46:30.189031057+02:00” level=info msg="Default bridge (docker0) is assigned with an IP a>
Jun 21 22:46:30 linuxmint dockerd[907]: time=“2021-06-21T22:46:30.468123708+02:00” level=info msg=“Loading containers: done.”
Jun 21 22:46:30 linuxmint dockerd[907]: time=“2021-06-21T22:46:30.616598831+02:00” level=info msg=“Docker daemon” commit=“20.10.2-0ubuntu1~20.04.2” >
Jun 21 22:46:30 linuxmint dockerd[907]: time=“2021-06-21T22:46:30.618019344+02:00” level=info msg=“Daemon has completed initialization”
Jun 21 22:46:30 linuxmint systemd[1]: Started Docker Application Container Engine.
Jun 21 22:46:30 linuxmint dockerd[907]: time=“2021-06-21T22:46:30.808527378+02:00” level=info msg=“API listen on /run/docker.sock”

this looked ok to me so i opened the browser and fired up the portaner ,but still site unreachable.
restarted the pc and tried again but still site unreachable.

I see no reason why rsync -a should yield any different result than a mv for the data-root folder’s content. In the past I successfully used mv (which works fine, if the same storage driver is used for the new new data-root folder as well) to move data to a new location. Another alternative is to start with a clean slate: just change the data-root folder in /etc/docker/deamon.json (which you already did) and do not copy/move any existing data from the previous data-root folder to the new location. Docker will create all required files when started after the deletion:
– stop the daemon: sudo systemctl stop docker
– remove the current data-root content: sudo rm -rf /media/data/docker/*
– start the deamon again: sudo systemctl start docker

If this is still not working, then the problem originates from something else.

Stopped the docker service ,deleted the content from the /media/data/docker and started the service but still not working, this is getting crazy.

do you think we can do remote, i can invite you remotely to my pc and maybe you can tell what i am doing wrong.

Ok, I just realized that after i deleted everything from this location /media/data/docker and started the service, my portainer container was gone, installed the portinater again, and now it is working. Perfect

Restarted the PC just to make sure that I am able to reach portainer, and it is working.

Thanks a lot Meyay for your guidance, you were a great help :slight_smile: