Categories
Docker Linux

Move all docker files to another location

  1. Stop the services
# sudo systemctl stop docker.service

# sudo systemctl stop docker.socket

2. Edit file

# sudo mcedit /lib/systemd/system/docker.service

3. Find

ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

4. Replace

ExecStart=/usr/bin/dockerd -g /home/docker -H fd:// --containerd=/run/containerd/containerd.sock

5. Create new directory

# mkdir -p /home/docker

6. Synchronize files

# rsync -aqxP /var/lib/docker/ /home/docker

7. Start services

# sudo systemctl daemon-reload

# sudo systemctl start docker

8. Check

# ps aux | grep -i docker | grep -v gre

9. If everything is ok you can remove old files:

# rm -rf /var/lib/docker/