π 2020-Jul-08 ⬩ βοΈ Ashwin Nanjappa ⬩ π·οΈ docker ⬩ π Archive
By default, Docker stores the data of its images, containers and volumes in the /var/lib/docker
directory. Sometimes, you may want to request Docker to store its data in a different directory or partition.
For example, on my computers I keep separate partitions for root /
and home /home
and the latter is much bigger than the former. So, I prefer that Docker use a directory in my /home
partition to store its data.
To change the data directory used by Docker:
/var/lib/docker
by removing all the images currently used by Docker:$ docker system prune -a
Create a directory for Dockerβs data whereever you want. I created one in my home partition: /home/joe/docker_data
.
Add the following lines to the /etc/docker/daemon.json
file:
"data-root": "/home/joe/docker_data",
"storage-driver": "overlay2"
$ sudo systemctl restart docker
When you pull down images, you will now see the new data directory getting populated.