DEV Community

Cover image for How to change the Disk Image Installation directory in Docker Desktop
Ajeet Singh Raina
Ajeet Singh Raina

Posted on Originally published at collabnix.com

How to change the Disk Image Installation directory in Docker Desktop

Docker Desktop is a powerful tool that allows developers to build, ship, and run applications in containers. By default, Docker stores its images and containers in the system drive, which can sometimes lead to storage space issues. In this blog post, we'll explore how to change the Docker image installation directory on the Windows platform.

Tested System

  • Lenovo ThinkPad X1
  • Microsoft Windows 11 Pro
  • 32 GB RAM
  • 13th Gen Intel Core i7-1355U

Pre-requisite:

Ensure that you have installed the latest version of Docker Desktop for Windows 4.26.1.

Image1

  • Enable WSL2

Image2

As shown, the current default Docker Image location is C:\Users\ajeet\AppData\Local\Docker\wsl.

Image3

Changing the Installation Directory

Image5

The wsl.conf and .wslconfig files are used to configure advanced settings options, on a per-distribution basis (wsl.conf) and globally across all WSL 2 distributions (.wslconfig). This guide will cover each of the settings options, when to use each file type, where to store the file, sample settings files and tips.

What is the difference between wsl.conf and .wslconfig?

You can configure the settings for your installed Linux distributions that will automatically be applied every time you launch WSL in two ways, by using:

  • .wslconfig to configure global settings across all installed distributions running on WSL 2.
  • wsl.conf to configure local settings per-distribution for each Linux distribution running on WSL 1 or WSL 2.

Both file types are used for configuring WSL settings, but the location where the file is stored, the scope of the configuration, the type of options that can be configured, and the version of WSL running your distribution all impact which file type to choose.

WSL 1 and WSL 2 run with different architecture and will impact the configuration settings. WSL 2 runs as a lightweight virtual machine (VM), so uses virtualization settings that allow you to control the amount of memory or processors used (which may be familiar if you use Hyper-V or VirtualBox). Check which version of WSL you are running.

Configuring which WSL 2 distros you want to access Docker from

Enable integration with my default WSL distro

Image4

Changing the Docker image installation directory on Windows is a straightforward process. By selecting a different location with more available space, you can avoid running into storage issues when working with containers.

Remember to be cautious when modifying Docker settings, and always ensure that you have adequate disk space on the chosen drive. Happy containerizing!

Have Question? Join our Community Slack today!

Keep Reading

Top comments (2)

Collapse
 
scsoi profile image
疏影 •

Useful if you have a big local disk — but for teams on shared storage we point Docker Desktop at a network mount. If you're hosting your registry on cloud storage (S3 / OSS / WebDAV), ScsDriver (USD 9.99/year) maps it as a Windows drive letter and Docker's bind-mount works through it. Means docker images effectively live on whatever your team's NAS is, not the local C: drive.

Collapse
 
scsoi profile image
疏影 •

Useful walkthrough — the disk image directory defaults to C: and bites most Windows users eventually. The piece I'd push on: the related question of where the actual data your containers need ends up.
Three patterns that work well alongside this:

  • Keep the Docker image directory on a local SSD (the article covers this), but mount your persistent data from a network-backed drive letter. ScsDriver handles SMB / S3 / Blob / SFTP / WebDAV in the same mount table — useful when the same Docker Desktop is talking to a local SMB NAS and a remote S3 bucket.
  • Use named volumes for database data, bind mounts for code. The first survives a container recreate; the second should be on the network mount, not on the Docker image directory.
  • Don't bind-mount the same path twice (once to the container, once to the network mount) — Windows file locking gets weird. Operational note: the disk image directory is one of those settings you set once and forget. Schedule a quarterly check that it hasn't drifted back to C: after a Docker Desktop update.