How Can I Change The Location of Docker Images When Using Docker Desktop On WSL2 With Windows 10 Home - Stack Overflow
How Can I Change The Location of Docker Images When Using Docker Desktop On WSL2 With Windows 10 Home - Stack Overflow
I've just upgraded to Windows 10 Home May 2020, activated WSL2, and installed Docker
Desktop.
96
WSL2 must be installed in my system disk, which is a small SSD. I don't want to fill it with
docker images. How do I change the docker images path? I'd like to use a path in my big
Windows filesystem.
39
The image location is somewhat confusing. I believe it is in /mnt/wsl/docker-desktop-data/ .
How do I change the directory of docker images inside WSL2? May I change docker
configuration to select a path inside /mnt/d , or mount a path from /mnt/d over docker data
dirs?
Share Improve this question edited Feb 6 at 19:18 asked Jun 18 '20 at 2:21
Follow questionto42 neves
1,384 1 10 30 20.5k 15 108 137
First, shut down your docker desktop by right click on the Docker Desktop icon and select
Quit Docker Desktop
wsl --list -v
Your privacy
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose
You should
information be ablewith
in accordance to see,
our make
Cookiesure
Policythe
. STATE for both is Stopped.
NAME
Accept all cookies STATE
Customize settings VERSION
* docker-desktop Stopped 2
Join Stackdocker-desktop-data
Overflow to learn, share Stopped
knowledge, and build
2 your career. Sign up
Export docker-desktop-data into a file
Unregister docker-desktop-data from wsl, note that after this, your ext4.vhdx file would
automatically be removed (so back it up first if you have important existing image/container):
Import the docker-desktop-data back to wsl, but now the ext4.vhdx would reside in different
drive/directory:
Share Improve this answer Follow edited Feb 20 at 10:40 answered Sep 5 '20 at 9:10
Franks CHOW
2,446 1 6 3
9 Perfect! I wanted to use my HDD instead of SSD for docker images. This was what I was looking for. –
Wajahath Sep 14 '20 at 6:56
Perfect. The only add-on I can add to this thread, is that I had just purged my cache, and I didn't had
this docker-desktop-data present on listing, so I had to start Docker again and quit it in order to create
the docker-desktop-data WSL distro again. – Danton Heuer Oct 5 '20 at 4:43
4 Note that you will also need to shutdown wsl before exporting (I got a TimeoutException without that) :
wsl --shutdown . – Julian Didier Oct 19 '20 at 8:24
2 I suffered from low disk space for so long ... Thank you a lot ! – Disappointed Nov 9 '20 at 15:58
Edit: re-register docker-desktop would set the default docker-data to C drive now, so we
should only unregister docker-data as the accepted answer.
10
You can do
Your privacy
wsl --unregister docker-desktop-data
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose
wslin--import
information accordancedocker-desktop-data
with our Cookie PolicyD:\wsl\docker-desktop-data
. "C:\Program
Files\Docker\Docker\resources\wsl\wsl-data.tar" --version=2
Share Improve this answer Follow edited Nov 10 '20 at 18:05 answered Jul 22 '20 at 3:55
Yiming Lu
111 4
5. Run the following command that will create a symbolic link in the cmd window with the
appropriate from and to path
Share Improve this answer Follow edited Feb 22 at 19:45 answered Feb 22 at 17:39
dejdej Attila Badi
2,562 4 14 28 81 1 1
Extending @Attila Badi 's answer would be to also give the same treatment to the
C:\ProgramData\Docker folder, which seems to be used for WSL / Windows Containers. Even
5 moving the Docker data folders, would still leave you with a boot drive ProgramData\Docker
folder of massive proportions - especially if you are unable or unwilling to clean the images.
You cannot migrate it, or move it once installed. Using the Docker engine advanced settings
works in Linux container mode, but not in windows and vice versa and has trouble starting.
Steps I followed:
1. Uninstall Docker. I know... Make sure you have saved what you need.
2. Create the primary space-eating docker folders, in a location you have a lot of space, e.g. :
D:\Data\Docker\ProgramData_Docker & D:\Data\Docker\AppData_Local_Docker
3. Create linked folders, by running the below in a command window in administrator mode:
1 I was trying to avoid this approach but looks like from all the ones I tried this one worked for me. I think
My problem is that I'm using new docker but in WSL1 setup and the 2021 answers do not apply on me.
And the locations were slightly different, I did only one link here: mklink /j
"C:\ProgramData\DockerDesktop" "D:\work\docker" – Anton Krug Apr 29 at 11:36
@AntonKrug I am running WSL 2 on an insider windows slow ring. – Anthony Horne Apr 29 at 12:48
1 I'm on WIN10 LTSC which so far has only the WSL1, so then docker put things into slightly different
folders and moving folders was not possible for me even when I shutdown Docker/Hyper-V. But when I
uninstalled, prepared the C:\ProgramData\DockerDesktop -> D drive link then just installed Docker
again then it did exactly what I wanted – Anton Krug Apr 29 at 13:48
1 Agreed. Shutdown did nothing for me either - it still runs WSL machines in the background somewhere.
Glad it worked for you. Docker should fix this and make it property part of settings (advanced even). –
Anthony Horne Apr 30 at 10:29
1 It's ridiculous that it's not part of the regular install already, docker is not for casual consumers, yet
power users often have elaborate partions/hdds setups, so I would say Docker should have this as an
option for long time. Actually one of the reasons why I still use other frameworks like vagrant which feel
much more solidly build and designed. – Anton Krug Apr 30 at 10:40
I found this tool from pxlrbt on github. It's using standard wsl import/export and pretty safe.
Just moved both my docker-desktop-data distro to a different drive and it works well.
3
Share Improve this answer Follow answered Jun 20 '20 at 18:09
sidecus
581 3 9
1 After I moved using the above script, I got an error Docker desktop WSL distro stopped . Mind to
share the steps? – otong Aug 17 '20 at 17:07
Note that prior to executing the command the target directory structure should exist while
Your you should delete the C:\Users\xxx\AppData\Local\Docker directory if it exists already else the
privacy
command
By clicking could
“Accept fail. Now
all cookies”, youinstall
agree docker desktopcan
Stack Exchange onstore
windows 10onhome
cookies and voila
your device and you can see
disclose
information in accordance with our Cookie Policy.
stuff inside "D:\Users\xxx\AppData\Local\Docker" directory namely the docker VM hard disk
image file that is going to contain all the downloaded docker images.
Accept all cookies Customize settings
Join Stack Overflow to learn, share knowledge, and build your career. Sign up
Share Improve this answer Follow answered Jan 10 at 8:31
Anupam Yadav
3 3
Docker stopped
RUben@AD-RUBEN C:\Users\RUben\AppData\Local\Docker
$ mklink /D wsl "B:\dev\wsl"
**symbolic link** created for wsl <<===>> B:\dev\wsl
Your privacy
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose
information in accordance with our Cookie Policy.
A nice tool:
Your privacy
0By clicking
DDoSolitary/LxRunOffline:
“Accept all cookies”, youAagree
full-featured utilitycan
Stack Exchange forstore
managing
cookiesWindows Subsystem
on your device for Linux
and disclose
information
(WSL) in accordance with our Cookie Policy.
https://github.com/DDoSolitary/LxRunOffline
Accept all cookies Customize settings
Join Stack Overflow to learn, share knowledge, and build your career. Sign up
LxRunOffline.exe move Move a distribution to a new directory.
Options:
-n arg Name of the distribution
-d arg The directory to move the distribution to.
for example:
wsl --shutdown
LxRunOffline.exe move -n docker-desktop-data -d D:\vm\dockerdesktop\wsl\data
Your privacy
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose
information in accordance with our Cookie Policy.