DOCKER

Moving Docker Runtime and Storage Location

For the Linux operating system, these steps document how to free up some space in the root volume of your operating system by moving the docker runtime location from /var/lib/docker/ to the /home volume.

The runtime directory is where Docker images, containers, and volumes are stored.

Stop Docker

sudo systemctl stop docker

# verify docker has stopped
ps aux | grep -i docker | grep -v grep    

Configure Docker daemon

Create or update the /etc/docker/daemon.json configuration file. e.g.,

sudo nano /etc/docker/daemon.json

Create the new location directory structure under /home. e.g.,

cd ~/

mkdir -p .local/share/docker

Enter the new /home Docker runtime and storage location in the configuration file for user gilfoyle in this example. e.g.,

daemon.json
{
    "data-root": "/home/gilfoyle/.local/share/docker"
}

Use rsync to transfer the files to the new location. e.g.,

sudo rsync -axPS /var/lib/docker/ /home/gilfoyle/.local/share/docker

docker runtime folders under home

Start Docker

sudo systemctl start docker

Remove the pre-existing files after testing.

rm -rf /var/lib/docker
  • If you had portainer deployed previously, you may need to redeploy it and remove any orphaned containers and volumes.
comments powered by Disqus