Creating Partition Drive E in a target windows Server using Docker - docker

Is it possible to create a new partition with a drive E: in a docker Windows container?
I tried option symbolic link in the registry and volume E in a dockerfile,it generates a drive in a container.But when i run this container in my localhost it doesnot create any E partition drive.
I also tried new partition powershell command to create new drive in the target windows host using dockerfile, but it shows like "msft doesnot have disknumber drive" in building the image itelf.
So what i need is, i dont have any drive other than c in my target windows host,so using dockerfile i need to create a drive by downloading my drive creation image as a base image.
Can anyone suggest me.
Thanks in advance

But i think Volume command in docker will create a disk drive in target windows like the below link Create D drive in a docker container.
Correct me if any wrong.

Related

VSCode how to open a local folder within a local docker container.....without devcontainers.json?

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 do I map Docker Sonarr /tv folder to my QNAP host media folder?

When I create a Docker Sonarr container it creates a couple of shared folders
e.g.
/tv -> /share/CACHEDEV1_DATA/Docker/container-station-data/lib/docker/volumes/6fed952ac3b86bca896db5396dd28ab397dd71fa329184427f301a1b34029613/_data
and my media is on my host /share/Multimedia/TV Series, but no matter what sort of softlink I create I can't get Docker Sonarr to see the contents of /share/Multimedia/TV Series. Could someone that has done this please advise me?
I should add that the QNAP runs the image in its Virtualisation Station so I don't start it with a CLI command.
Even if I map my media folder to this folder it doesn't work i.e. I can get a directory list of my media in the path below.
/share/CACHEDEV1_DATA/Docker/container-station-data/lib/docker/volumes/6fed952ac3b86bca896db5396dd28ab397dd71fa329184427f301a1b34029613/_data/tv
I figured it out. When you create the container don't use the default New Volume! Instead use Volume from host, you may or may not need to set permissions. See the linuxserver/sonarr page for more complete instructions on permissions.

Move docker images directory out of C drive on windows

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.

Docker - Windows containers: How to use custom paths

I have been trying to figure out where docker is trying to store images when I am doing a docker pull for windows containers but am unable to find the exact location.
Even though I have created Junction links for all the docker files I could find in the C Drive and also configured Hyper-V to store everything in the external drive, when I do a docker pull, it still starts downloading in the C drive which eventually fails as I have no space available there.
Can someone help me here please ? I am trying to do a POC for windows containers and cannot pull down the large images :(
Thanks in advance,
Vishal

Change Docker native images location on Windows 10 Pro

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

Resources