We are using cookies in the page. If you use the page you agree for the cookies.
Close
Moving Docker's storage directory to different location
-
Edit file /lib/systemd/system/docker.service
and replace line:
ExecStart=/usr/bin/dockerd -H fd:// $DOCKER_OPTS
with following line:
ExecStart=/usr/bin/dockerd -g /new/path/docker -H fd:// $DOCKER_OPTS
where /new/path/docker specifies destination directory that shold store Docker's images.
-
Stop Docker service:
sudo systemctl stop docker
-
Make sure that Docker service stopped properly:
sudo ps aux | grep -i docker | grep -v grep
If the command above does not output anything that it is all OK.
-
Because Docker systemd unit configuration file has changed you have to reload systemd configuration.
You can do it with following command:
systemctl daemon-reload
-
Move all content of /var/lib/docker directory to the new desired location:
sudo rsync -aqxP /var/lib/docker/ /new/path/docker
If you want to have access to the new Docker's storage area then you should change its owner nad group:
sudo chmod -R username:groupname /new/path/docker
-
Start Docker service:
sudo systemctl start docker
-
Make sure that the service runs properly:
ps aux | grep -i docker | grep -v grep
If the command above will give some output then everything is OK.