Docker Desktop: Change images & containers directory

Last updated on September 12, 2022 A Goodman Loading... 2 comments

Under some circumstances, you might want to change the folder that stores your Docker images and containers. For example, you are running Docker Desktop on a Windows laptop or a Macbook with only 256GB or 512GB of storage and it is almost out of free space. In this case, you can move your images and containers to a bigger drive or external storage.

By default, Docker Desktop stores your images and containers at:

  • C:/ProgramData/DockerDesktop/vm-data on Windows
  • /Users/<your username>/Library/Containers/com.docker.docker/Data/vms/0/data on Mac

Important Note: If you’re using WSL (Windows Subsystem for Linux) 2 Backend, see the later section of this article

The Steps

If you’re running Docker Desktop on a Mac or a Windows computer (without using WSL 2 Backend), then you can change this location by following the steps below:

1. Go to your Docker Desktop dashboard and select Settings:

2. Navigate to Resources > Advanced and scroll down a little bit to see the Disk image location area:

3. Click on the Browse button and choose a new directory for your images and containers:

4. Last but not least, click the Apply & Restart button to finish:

Docker Desktop will take care of the rest.

The Steps For Windows Users with WSL 2 Backend

A large portion of Windows users run Docker Desktop on WSL 2 (the Windows Subsystem for Linux built by Microsoft) due to various benefits such as:

  • Leveraging Linux workspaces and avoiding having to maintain both Linux and Windows build scripts
  • Improving file system sharing, and boot time and allowing access to some cool new features for Docker Desktop

To change containers and images directory in this case, walk through the following steps:

1. Exit Docker Desktop

2. Shutdown WSL by executing this command:

wsl --shutdown

3. Export Docker Desktop data to your home screen (you can choose another place if you like):

wsl --export docker-desktop-data C:\Users\YOURUSERNAME\Desktop\data.tar

4. Unregister current Docker Desktop data:

wsl --unregister docker-desktop-data

5. Import the exported data to your desired location (for example, a folder named kindacode in the hard drive E):

wsl --import docker-desktop-data E:\kindacode\ C:\Users\YOURUSERNAME\Desktop\data.tar --version 2

You might have to perform this step twice if you run into some network trouble.

Further reading:

You can also check out our Docker topic page for the latest tutorials, examples, tips, and tricks.

Subscribe
Notify of
guest
2 Comments
Inline Feedbacks
View all comments
LostOnTheLine
LostOnTheLine
26 days ago

This doesn’t work with WSL2 which has been the standard for Docker for about a year. Resources > Advanced just says Resources Advanced You are using the WSL 2 backend, so resource limits are managed by Windows. You can configure limits on the memory, CPU, and swap size allocated to WSL 2… Read more »

Related Articles