Change Docker native images location on Windows 10 Pro

江枫思渺然 提交于 2020-12-24 07:11:32

问题


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.

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 ?


回答1:


Docker Version : 2.2.0.3 (42716)

  1. Right-click on docker icon on desktop tray

  1. Click on Settings

3 Click on Resources from the left-hand menu then under the Disk Image location click on browse and change the location

  1. Click on apply and restart



回答2:


I found a solution here

Docker native, on Windows, runs in a Hyper-V virtual machine.

Move existing docker VM

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.

  • Right-click MobyLinuxVM
  • Select Move
  • Select desired location

Set location of futures Hyper-V VMs

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'




回答3:


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.




回答4:


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.




回答5:


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




回答6:


In 2020 to "Change Docker native images location on Windows 10 Pro" is,

  1. quit docker desktop
  2. open/edit configuration file "C:\ProgramData\Docker\config\daemon.json"
  3. add setting "data-root": "D:\Virtual Machines\Docker"
  4. now start docker desktop
  5. run the command "docker info" to see the setting "Docker Root Dir: D:\Virtual Machines\Docker"
  6. pull docker images e.g.: docker pull mongo
  7. you can find the downloaded images in folder "D:\Virtual Machines\Docker\windowsfilter"



回答7:


For Those looking in 2020. The following is for Windows 10 Machine:

  1. In the global Actions pane of Hyper-V Manager click Hyper-V Settings…
  2. Under Virtual Hard Disks change the location from the default to your desired location.
  3. Under Virtual Machines change the location from the default to your desired location, and click apply.

  1. Click OK to close the Hyper-V Settings page.


来源:https://stackoverflow.com/questions/40465979/change-docker-native-images-location-on-windows-10-pro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!