welw | About_me Blog WebAssembly

Docker: I would like to save images to /srv/docker and not /var/lib/docker, because my /var/ partition is only 7 GB

To change the Docker data directory to /srv/docker and save your images there, follow these steps:

  1. Stop Docker service: bash sudo systemctl stop docker

  2. Copy existing Docker data to the new location: bash sudo rsync -aP /var/lib/docker/ /srv/docker/

  3. Set the new data directory by editing the Docker daemon configuration file (/etc/docker/daemon.json): json { "data-root": "/srv/docker" }

  4. Restart Docker service to apply changes: bash sudo systemctl start docker

Ensure that /srv/docker has sufficient space and appropriate permissions.