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:
- Install Visual Studio Code
- Install Docker Desktop for Windows
- Ensure that you have installed the latest version of Docker Desktop for Windows 4.26.1.
![Image1](https://i0.wp.com/res.cloudinary.com/practicaldev/image/fetch/s--HTLcwBit--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7fdt8wguy1a43morcdam.png?ssl=1)
2. Ensure that “Use the WSL2 based engine” is enabled under Dashboard > Settings > General.
![Image2](https://i0.wp.com/res.cloudinary.com/practicaldev/image/fetch/s--8rdmucV6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u03s1112ge5c7mfqk039.png?ssl=1)
3. Open Settings > Resources > WSL Integration option.
As shown, the current default Docker Image location is C:\Users\ajeet\AppData\Local\Docker\wsl.
![Image3 embed](https://i0.wp.com/res.cloudinary.com/practicaldev/image/fetch/s--vL522yLU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fhjhl1e4zjb5i52tgah1.png?ssl=1)
Changing the Installation Directory
Go ahead and try changing the default Disk Image location.
![Image5](https://i0.wp.com/res.cloudinary.com/practicaldev/image/fetch/s--j5Yb0RXS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n6ifrfpypvyqnglybef5.png?ssl=1)
Quick Note: The Resource section also allows you to configure limits on the memory, CPU and Swap size allocated to WSL2 by editing the .wslconfig file.
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
You can “Enable integration with my default WSL distro” under Resources > WSL Integration option.
![Image description](https://i0.wp.com/res.cloudinary.com/practicaldev/image/fetch/s--mxj5AfRg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/in9d441rtmyqbkz0g9j6.png?ssl=1)
Conclusion
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!
Keep Reading
-
Docker and Wasm Containers – Better Together
Learn how Docker Desktop and CLI both manages Linux containers and Wasm containers side by side.
-
Lumin’s Latest Innovations in PDF Technology
Discover how Lumin’s cutting-edge PDF editor streamlines document collaboration and editing tasks, empowering your team to work smarter. #PDFediting #collaboration #productivity
-
Easy QR Code Maker: Tools and Tips
QR codes have become an essential tool for businesses and individuals looking to share information quickly and efficiently. Whether you’re promoting a product, sharing contact information, or linking to a website, a free qr code generator can make the process straightforward and hassle-free. In this article, we will explore the best tools and tips for…
-
Real-world applications of Large Language Models(LLM) Across Industries
Large Language Models (LLMs) have revolutionized a wide range of industries with their advanced capabilities in generating human-like text. This extends far beyond just natural language processing, into numerous practical applications across diverse sectors. This blog explores some of the most impactful real-world use cases of LLMs, drawing insights from a detailed analysis conducted by…