Select Page

How to change Docker directory

How to change Docker directory

Maintaining adequate disk space is a crucial task we perform in our outsourced server management services. Lack of free space can often lead to server crashes.

In Docker machines, ‘/var/lib/docker’ is the directory where the Docker images and the container data are stored by default, when Docker is installed:

Docker default data directory

Docker default data directory


But when the /var partition gets filled up as more and more containers are created, the system may soon run out of space. That’s when we need to change the default directory for Docker images.

Today we’ll discuss how to change the default installation directory for Docker.

Setup and manage your Docker system


How to change Docker default directory

To change Docker’s images directory ‘/var/lib/docker’ to another partition with more space, the option ‘-g’ is used with the Docker daemon.

For instance, in our Docker machine, the default directory was ‘/var/lib/docker/aufs’ as seen:

Docker default directory

Docker default directory


Here’s how we changed it to another directory:

1. Since our /var partition was running out of space, we created a new partition ‘/mnt/docker’.

2. We then edited the Docker configuration file ‘/etc/default/docker’ and gave the start-up option -g to specify this new directory.

Change Docker directory in configuration file

Change Docker directory in configuration file


3. We then restarted the Docker service

root default # service docker restart
docker stop/waiting
docker start/running, process 20081


4. After the restart, Docker started using the new directory ‘/mnt/docker’ as seen here:

Docker directory changed to /mnt

Docker directory changed to /mnt


From now onwards, the newly created Docker containers and images would be stored in the new directory ‘/mnt/docker’.

[ Are your spending too much time managing your Docker containers? Our Docker experts take care of your infrastructure and ensure its smooth functioning. ]

Disk space issues in Docker ?

Wish you had more time to focus on your business? Let us help you.

Our engineers will assist you to setup, monitor and manage your Docker infrastructure 24/7.


Bobcares provides Outsourced Hosting Support and Outsourced Server Management for online businesses. Our services include Hosting Support Services, server support, help desk support, live chat support and phone support.

Submit a Comment

Your email address will not be published. Required fields are marked *

Bobcares is a server management company that helps businesses deliver uninterrupted and secure online services. Our engineers manage close to 51,500 servers that include virtualized servers, cloud infrastructure, physical server clusters, and more.