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 ?
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
Docker Version : 2.2.0.3 (42716)
Right-click on docker icon on desktop tray
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
Click on apply and restart
In 2020 to "Change Docker native images location on Windows 10 Pro" is:
quit docker desktop
open/edit configuration file C:\ProgramData\Docker\config\daemon.json
add setting "data-root": "D:\\Virtual Machines\\Docker"
now start docker desktop
run the command docker info to see the setting Docker Root Dir: D:\Virtual Machines\Docker
pull docker images e.g.: docker pull mongo
you can find the downloaded images in folder D:\Virtual Machines\Docker\windowsfilter
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'
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.
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.
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
For Those looking in 2020. The following is for Windows 10 Machine:
In the global Actions pane of Hyper-V Manager click Hyper-V
Settings…
Under Virtual Hard Disks change the location from the default to
your desired location.
Under Virtual Machines change the location from the default to your
desired location, and click apply.
Click OK to close the Hyper-V Settings page.
If issues using the Docker Desktop GUI, when using Hyper-V:
Shutdown Docker Desktop
Edit c:\users\[USERNAME]\AppData\Roaming\Docker\settings.json
You need to edit dataFolder entry. Use Double backslashes.
eg: "dataFolder": "D:\\Demo\\Hyper-V\\DockerDesktop\\DockerDesktop"
Restart Docker Desktop
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.
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": "".
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
Just configuration from Docker Desktop worked for me (Latest Version V20.10.8)
Steps
Go to settings
Select 'Docker Engine' option
Add property "data-root": "D:\\Docker" in configuration file
Apply and Restart
Settings
Related
I want start a docker container that I have created, and then mount a local folder to it in a way that doesn't make use of a devcontainers.json file. This is because I would like to test the same local repo out with multiple docker containers and editing the devcontainers.json file is a pain because I have to edit every time I want to change the docker image - where really I just want to do something like:
Dev Containers: Open Local Folder in Container
Choose Local Folder
Choose a docker container that is already running
The problem is that in step 3 I only see options to choose from pre-made base images i.e. Ubuntu 22.04. I can't see anywhere in the list any of my docker containers that I am running. Have I missed any functionality? Does what I'm asking exist......or must I use a devcontainers.json file?
If I correctly understood your issue:
Once you install Microsoft's Docker extension from the VS Code extensions' tab (ctrl + shift + x), you'll be able to do that.
This extensions have a "CONTAINERS" tab, where you can open another VSCode window inside a selected container's directory or attach a terminal to the container and manage the system.
Just right-click on the desired container and you'll see the options.
How to set the shared drives in Docker for Windows? I am using the latest version 18. Stable and Edge. My settings screen is shown below. It's missing some options like Shared Drives, Advanced and Network, which are shown in the second image. Why am I missing these options?
My settings:
Screen from a website:
Seems you are Running Docker for Windows using "Windows Containers". If you switch to "Linux containers" you'll see "Shared Drives" option. Take a look this video.
According Docker documentation: shared drives for Windows containers is not implemented.
Volume mounting requires shared drives for Linux containers (not for
Windows containers).
Update:
Since 2018, Docker for Desktop is using a new UI. I recorded a new video showing how to solve this problem.
Update:
If you are using WSL2 you will be experiencing same problem. Take a look this video.
In new UIs they are placed under resources
Ended up here, because the "Shared drives" was missing on my docker settings. If you are missing it too, but docker is set for linux container then it is because WSL 2.
Because if you are using Docker on WSL 2, there is no such option, but you can directly attach volumes from filesystem with docker run -v c:\...\your-folder:/mount ... without specifying it in docker settings.
I have pulled few windows images from docker hub which are stored in my C-Drive by default. (C:\ProgramData\Docker)
Please explain how I can move those to a different drive like D.
The simplest solution is to move the directory to the intended location, and then create a directory junction from the old location to the new one:
move C:\ProgramData\Docker D:\mypath\Docker
mklink /j C:\ProgramData\Docker D:\mypath\Docker
this causes Docker to believe that the data is still at C:\ProgramData\Docker, even though it isn't, and it will not take up any space on C:.
You can find a few other solutions at https://github.com/docker/for-win/issues/185 , but it appears that they don't work 100%.
As described in the following article, worked for me in a Windows Server 2019 environment running Docker client and server version 20.10.7.
https://www.ntweekly.com/2019/09/20/how-to-change-docker-storage-data-folder-on-windows-server-2016/
Stop the docker service
stop-service docker
Edit following file, create it if not already there:
C:\ProgramData\Docker\config\daemon.json
Add data-root element to the json string:
{
"data-root": "e:\\DockerData"
}
Restart the service:
restart-service docker
Beware, your images and containers aren't automatically moved to the new location, you need to manually relocate them.
So I am running on win10 with Hyper-V.
Docker is currently using a harddrive instance thats stored on my C drive (which is an ssd with very little space) I want it on my sshd which is my D drive.
The following is what I tried and has failed, because it looks like Docker just jumps back to its default every time.
change is using the docker interface in the advance section (to a copy of the vhdx file in the d drive)
changing it manually in the hyperv manager by having it migrate the harddrive to a new location
As well as other variations where I restart my computer after doing these.
Use docker > settings > advanced > change vhd location. Notice, you should select an empty directory instead of copy the VHD file by yourself.
Stop / Shutdown Docker
Copy/Move the existing .vhdx from
C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks\MobyLinuxVM.vhdx
to
D:\MobyLinuxVM.vhdx (your preferred ssd location)
Edit the Docker settings.json file (%APPDATA%\Docker\settings.json) and configure
"MobyVhdPathOverride": "D:\MobyLinuxVM.vhdx"
Now start the Docker again - the changes should be in place.
When I was having similar problems in that simply changing the Disk image location path would not stick upon a docker restart; this process worked for me:
Create the destination folder, make sure its empty (so no copies of MobyLinuxVM.vhdx)
In Docker>Reset>Restore to factory defaults... restore your docker to factory defaults
In Docker>Settings>Shared Drives give the drive( in your case, D) shared access to docker. Hit apply.
In Docker>Settings>Advanced browse under Disk image location to your destination folder. Hit Apply.
ref: https://github.com/docker/for-win/issues/2063
This is DockerDesktop verison 4.7.1.
Click on the docker icon on the taskbar and go to settings or right click the docker icon on the taskbar and select settings. The window below will popup.
Navigate to the Resources on the left pane and scroll down (if Disk Image Location is not in view). Click on Browse and select an empty folder of your choice. Click on Apply and Restart and Docker Desktop will move the .vhdx from C:\Users\Public\Documents\Hyper-V\Virtual hard disks to your select folder.
If Docker Desktop encounters an error, close Docker Desktop and navigate to C:\Users\<User>\AppData\Roaming\Docker\settings.json and edit the "dataFolder": "D:\\Hyper-V\\Virtual hard disks\\DockerDesktop", to your destination folder. Restart Docker Desktop.
My root problem is that I need to support a local docker registry, self-signed certs and whatnot, and after upgrading to Docker for Mac, I haven't quite been able to figure out how to pass in options, or persist options, in the docker/alpine image running via the new and shiny xhyve that got installed with Docker for Mac.
I do have the functional piece of my problem solved, but it's very manual:
screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
log in as root
vi /etc/init.d/docker
Append --insecure-registry foo.local.machine:5000 to DOCKER_OPTS; write file; quit vi.
/etc/init.d/docker restart
Now, if from the perspective of the main OS / OSX, Docker is restarted -- like a simple reboot of the computer -- of course this change and option is lost, and I have to go through this process again.
So, what can I do to automate this?
Am I missing where DOCKER_OPTS may be set? The /etc/init.d/docker file, internally, doesn't overwrite the env var, it appends to it, so this seems like it should be possible.
Am I missing where files may be persisted in the new docker image? I admit I'm not as familiar with it than the older image that I believe was boot2docker based, where I could have a persisted volume attached, and an entry point where to start these modifications.
Thank you for any help, assistance, and inspiration.
Go to Docker preferences (you can find icon on main panel)
Advanced -> Insecure docker registry
Advanced settings pictures