Open file /lib/systemd/system/docker.service with your favorite text editor and replace the following line where /new/path/docker is a location of your new chosen docker directory:
FROM:
ExecStart=/usr/bin/docker daemon -H fd://
TO:
ExecStart=/usr/bin/docker daemon -g /new/path/docker -H fd://
When ready stop docker service:
systemctl stop docker
It is important here that you have completely stopped docker daemon. The following linux command will yield no output only if docker service is stopped:
ps aux | grep -i docker | grep -v grep
If no output has been produced by the above command, reload systemd daemon:
systemctl daemon-reload
Once this is done create a new directory you specified above and optionally rsync current docker data to a new directory:
mkdir /new/path/docker
rsync -aqxP /var/lib/docker/ /new/path/docker
At this stage we can safely start docker daemon:
systemctl start docker
Confirm that docker runs within a new data directory:
root 2095 0.2 0.4 664472 36176 ? Ssl 18:14 0:00 /usr/bin/docker daemon -g /new/path/docker -H fd://
root 2100 0.0 0.1 360300 10444 ? Ssl 18:14 0:00 docker-containerd -l /var/run/docker/libcontainerd/docker-containerd.sock --runtime docker-runc```
All done.
этот способ давно устаревший
Обсуждают сегодня