Update docker containers’ default storage location on Ubuntu
Mar 14, 2023
The storage location of Docker images and containers [1]
A Docker container consists of network settings, volumes, and images. The location of Docker files depends on your operating system:
- Ubuntu:
/var/lib/docker/
Change storage location [2]
Another often posted solution is to stop Docker:
sudo systemctl stop docker
Edit the /etc/default/docker
file by adding the new location with the -g
in the DOCKER_OPTS
line:
DOCKER_OPTS="-dns 8.8.8.8 -dns 8.8.4.4 -g /mnt/newlocation"
Then start Docker again:
sudo systemctl start docker=
Reference
[1] https://www.freecodecamp.org/news/where-are-docker-images-stored-docker-container-paths-explained/