79185506

Date: 2024-11-13 15:14:03
Score: 0.5
Natty:
Report link

This is how i did:

  1. First I stopped docker service and socket.

sudo systemctl stop docker.service

sudo systemctl stop docker.socket

2.Then I went to systemd file of docker and added the location of new directory:

sudo vim /lib/systemd/system/docker.service

We need the edit the line begins like that: ExecStart=/usr/bin/dockerd -H fd://

Edit the line by adding --data-root like :

ExecStart=/usr/bin/dockerd --data-root /mnt/new/docker -H fd:// --containerd=/run/containerd/containerd.sock

(/mnt/new/docker is the new directory I want to use in my case.)

  1. Thenrsync command to sync old with new docker root path :

rsync -avxP /var/lib/docker/ /mnt/new/docker

  1. Restart the deamon:

    sudo systemctl daemon-reload

Now you can restart your docker:

sudo systemctl start docker    

Check if it works as expected:

docker info | grep "Docker Root Dir"  
Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: berkayln