At some point we all want to store Docker images and volumes on a different drive, to avoid the system drive being filled up as the volumes grow. Here’s how.
First stop the docker service. Then the volumes can be moved from the default location at
/var/lib/docker to the new location.
$> sudo service docker stop $> sudo mv /var/lib/docker /srv/new-drive/new-docker-root
Next the configuration of the docker daemon is edited to point to the new location of the volumes.
$> sudo nano /etc/docker/daemon.json
The next step may not be necessary, but it is a good habit to do it anyway. Kindly reload the docker daemon and restart the docker service. Forgetting this step can cause a lot of lost time and confusion.
$> sudo systemctl daemon-reload $> sudo service docker start
Having a look at the output of
docker info shows that the docker volumes are successfully recognized at their new location.
$> docker info Server: ... Total Memory: 15.35GiB Name: none.off.your.beezwax ID: V7DW:LNVC:UM4W:VDAD:WC2H:TKM6:AXNW:MK2J:BGV2:OFOO:WBAR:BNMO Docker Root Dir: /srv/new-drive/new-docker-root Debug Mode: false ...
Looks alright to me. Finally start up those docker containers again.
$> docker-compose up -d Creating network "nextcloud_default" with the default driver Creating nextcloud_db_1 … done Creating nextcloud_app_1 … done
Leave a Reply