Reputation: 2657
This is not a duplicate of Change Docker machine location - Windows
I'm using docker native, version 1.12.1-stable (build: 7135) on Windows 10 Pro with Hyper-V enabled. So docker is not running with VirtualBox nor do I have the folder C:\Users\username\.docker
I'd like to move docker's images, caches, ... to my secondary drive D:\
I guess I should edit the Docker Daemon configuration.
I tried to add "graph": "/D/docker"
. Docker started correctly but I couldn't pull any image because of an error
open /D/docker/tmp/GetImageBlob135686954: no such file or directory
How to tell docker to use another path to store its images, etc ?
Upvotes: 108
Views: 159285
Reputation: 403
You can use
wsl --manage <distro_name> --move <new_location>
Upvotes: 0
Reputation: 2701
2023 Update:
Open up docker desktop GUI. On the left sidebar, there's a tab titled Extensions followed by 3 dots/Menu. click it and a toggle menu will appear, click on settings. Click the Resources tab and then click Browse. Update your image location. Here's what you'll see.
Upvotes: 7
Reputation: 666
From: https://github.com/microsoft/WSL/issues/4699#issuecomment-658369676
He created a symlink pointing to the new folder location. By running:
$ErrorActionPreference = "Stop"
$newLocation = "E:\VMs\WSL2\"
cd "~\AppData\Local\Docker\wsl\data"
wsl --shutdown
Optimize-VHD .\ext4.vhdx -Mode Full
mkdir $newLocation -Force
mv ext4.vhdx $newLocation
cd ..
rm "data"
New-Item -ItemType SymbolicLink -Path "data" -Target $newLocation
He also wrote a blog post going into more detail: http://nuts4.net/post/moving-wsl2-vhdx-file-to-a-different-location
Upvotes: 2
Reputation: 3775
Docker Desktop now can use WSL 2 Backend. In this mode, you need to move the wsl data.
In my case (Windows10 with Docker Desktop) none of the above solutions helped me, but I found the solution; run these commands.
This command changes the docker directory to drive D:
(don't forget to quit docker desktop first)
wsl --shutdown
wsl --export docker-desktop-data docker-desktop-data.tar
wsl --unregister docker-desktop-data
wsl --import docker-desktop-data D:\docker-new-repo\ docker-desktop-data.tar --version 2
And now you can delete .tar file
There is a very good blog post explaining everything:
https://dev.to/kimcuonthenet/move-docker-desktop-data-distro-out-of-system-drive-4cg2
Upvotes: 209
Reputation: 7
Just configuration from Docker Desktop worked for me (Latest Version V20.10.8)
Steps
"data-root": "D:\\Docker"
in configuration fileUpvotes: -2
Reputation: 107
If issues using the Docker Desktop GUI, when using Hyper-V:
c:\users\[USERNAME]\AppData\Roaming\Docker\settings.json
dataFolder
entry. Use Double backslashes."dataFolder": "D:\\Demo\\Hyper-V\\DockerDesktop\\DockerDesktop"
You can also use the above if Docker Desktop loses track of where you data folder is, as the GUI doesn't allow you to set it to a previously used location.
Upvotes: 6
Reputation: 1539
I would recommend looking at Microsoft documentation docker engine on windows, it's the daemon.json
file that allows to change the setting "data-root": "".
Upvotes: 1
Reputation: 565
In 2020 to "Change Docker native images location on Windows 10 Pro" is:
C:\ProgramData\Docker\config\daemon.json
"data-root": "D:\\Virtual Machines\\Docker"
docker info
to see the setting Docker Root Dir: D:\Virtual Machines\Docker
docker pull mongo
D:\Virtual Machines\Docker\windowsfilter
Upvotes: 36
Reputation: 13966
Edit the Docker Daemon configuration and use "data-root": "D:\\docker"
instead of "graph": "/D/docker"
.
That will move all the newly downloaded images to D:\docker
folder.
For Old Docker version use graph
"graph": "D:\\docker"
, "graph" has been deprecated.
Upvotes: 21
Reputation: 489
For Those looking in 2020. The following is for Windows 10 Machine:
Upvotes: 6
Reputation: 1596
Docker Version : 2.2.0.3 (42716)
3 Click on Resources from the left-hand menu then under the Disk Image location click on browse and change the location
Upvotes: 69
Reputation: 2974
None of these steps worked for me. After reboot or a Docker restart, it would move back to the original path. What worked for me is using Junction
stop docker engine
create a target folder in the new location:
mkdir d:\docker\vhd
copy the folder Virtual Hard Disks
to the target folder
rename (and backup) the original folder
rename “C:\Users\Public\Documents\Hyper-V\Virtual hard disks” “C:\Users\Public\Documents\Hyper-V\Virtual hard disks_backup”
create a hard symbolic link (junction)
junction.exe "C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks" "d:\docker\vhd\Virtual Hard Disks"
start docker engine
Upvotes: 9
Reputation: 615
There is an easier way to do this: Go to Docker Settings > Advanced > Change "Disk image location" and click "Apply" when prompted. Docker engine will shut down the VM and move it for you to the new location.
Warning: new location must not be compressed. If it is then Docker will not show you any error, just won't change location.
Upvotes: 18
Reputation: 2657
I found a solution here
Docker native, on Windows, runs in a Hyper-V virtual machine.
I have to move the VM used by docker to the desired location. I did this using the GUI of Hyper-V manager. The VM for docker is called MobyLinuxVM.
And to be sure futures VMs of Hyper-V will be stored on my secondary drive, I followed those instructions
In a powershell terminal (destination folders must exist)
SET-VMHOST –computername <computer> –virtualharddiskpath 'D:\Hyper-V_Virtual-Hard_Disks'
SET-VMHOST –computername <computer> –virtualmachinepath 'D:\Hyper-V_VMs'
Upvotes: 33