Modifying image storage location with Window Subsystem for Linux and Docker Desktop for Windows

While starting to explore Docker Desktop on Windows I found the documentation a bit confusing in some areas. Specifically I was curious to see where Docker stores it’s images and how to modify that storage location. I have a 6TB drive I like to storage large files on and the standard system “C” drive was not going to cut it.

I initially explored the Docker desktop settings looking for where I could set a path for data storage. According to Windows Docker documentation there should be an ADVANCED item under Resources in the settings. Upon opening settings I found no such value.

Docker desktop settings

This was strange! Why couldn’t I see these settings? I switched over to the Docker Engine section…

Docker Engine config settings

Ok this is perhaps a bit more helpful. JSON configuration data so perhaps there is a setting for setting the location of Docker image data. Yes there is! The storage location is referenced as data-root.

After adding data-root entry in the JSON block which can be done directly in the Docker Engine text form I ran a restart which… failed! Something further was needed.

I found several articles suggesting setting up a file daemon.json. Microsoft has a great overview of this process in their documentation here.

  x:\ProgramData\Docker\config\daemon.json

In my case this file didn’t exist but as outlined from the documentation above it’s fine to create it.

After creating a daemon.json file I restarted the docker service and… still no change in image storage location. Something was definitely not lining up.

The lightbulb moment

I finally tracked the source of my confusion to not understanding how Docker Desktop was dealing with WSL. If unfamiliar in brief WSL is…

Windows Subsystem for Linux (WSL) is a compatibility layer for running Linux binary executables (in ELF format) natively on Windows 10 and Windows Server 2019.

Wikipedia

In my case because I already had WSL installed that became the default container platform. I’m not sure if WSL is always chosen as the preferred container platform but it was for me.

To switch over to the ability to interact with Windows containers you have to explicitly perform that switch off the Docker Desktop systray icon…

Switching to Windows containers

Now when you go into Settings still no ADVANCED section but… under Docker Engine we can see the daemon.json content…

Setting the Docker data-root path

Changes done here within the Docker settings do get stored in the daemon.json file.

Linux container images

After figuring my confusion on the Windows side I wanted to switch back to Linux containers and see if I could track down where the Docker images were being downloaded to. You can switch back to Linux containers off the systray in the same way we switched over to the Windows containers…

Switching to Linux containers

After a better understanding of how Docker was interacting with WSL and figuring that WSL was likely hiding much of it’s Linux file data internally somewhere I opened a WSL shell and started exploring…

Location of docker image data under WSL

Voila!

This was all a bit tricky in that you won’t find these images in a host Windows 10 search.

Conclusions

Eventually I was able to track down where everything was located. The main takeaways…

  • Using Docker Desktop you need to explicitly switch to the particular platform (Windows/Linux) you want to interact/work with off of the systray icon
  • The preferred form of configuration for the Docker daemon or service seems to be using the configuration file daemon.json or configuration values under Docker Engine

Leave a Reply

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