microsoft/Windows-Containers

Get-Volume does not work in container : No MSFT_Volume objects found with property 'DriveLetter' equal....

david-garcia-garcia opened this issue · 2 comments

Describe the bug

When mounting local volumes using Docker Desktop, the sector size cannot be retrieved, this is an error from Microsoft SQL Server 2022:

An unexpected error occurred while checking the sector size
for file 'd:\data\testsdtsd.mdf'. Move the file to a local
NTFS volume, where the sector size can be retrieved. Check the
 SQL Server error log for more information.

Upon further investigation, powershell is not able to retrieve drive information for any drive at all:

Get-Volume C:\ | Format-List AllocationUnitSize, FileSystemLabel
Get-Volume : No MSFT_Volume objects found with property 'DriveLetter' equal to 
'c'.  Verify the value of the property and retry.

To Reproduce

You don't even need to mount a drive. Just start a container and run:

Get-Volume C:\ | Format-List AllocationUnitSize, FileSystemLabel

Expected behavior
Not sure. MSSQL Server seems to work, but this might break existing applications.

Configuration:

  • Edition: Windows 11
  • Base Image being used: mcr.microsoft.com/windows/servercore:ltsc2022
  • Container engine: Docker Desktop
  • Container Engine version 24.0.7

Hi, thanks for raising this Issue. I believe you're asking why the command Get-Volume is failing on a Docker volume. When you create a Docker volume (e.g., docker create <vol-name>), that volume isn't actually managed by your host operating system. Instead, that volume is created inside the Docker VM.

If you do docker volume inspect <vol-name>, it'll probably show that the mountpoint is at C:\ProgramData\Docker\volumes. However, if you open up File Explorer and try to navigate to that path, it won't let you. That's because the volumes folder is living inside the Docker VM.

Commands like Get-Volume won't work because your host file system isn't managing that volume so it can't provide any details because it doesn't even have access to it. This is actually intentional because Docker wants to streamline the management of these volumes. Similarly, they don't provide a lot of options for gathering data about the volume such as sector size.

If there's specific info you need about your Docker volume, let us know and we can try to explore a workaround (if it's possible). Otherwise, this is by design and not a bug.

@ntrappe-msft I am not conviced about the result of the analysis / explanation.

[..] Get-Volume is failing on a Docker volume. When you create a Docker volume (e.g., docker create <vol-name>), that volume isn't actually managed by your host operating system. Instead, that volume is created inside the Docker VM.

The results I am showing are when running the commands inside a Windows container in a Windows node in a managed AKS cluster. So there is no Docker VM, or even docker involved. Indeed, there is no virtualization involved because this is a windows node with windows container, so pure containers + containerd + kubelet.

This logs if from Microsft SQL Server when running in a windows container in the aformementioned scenario:

[00:07:29] [System:MSSQLSERVER] Error The operating system returned the error '144(The directory is not a subdirectory of the root directory.)' while attempting 'GetVolumeInformation' on 'g:\data\' at 'storagedmv.cpp'(468). 

Get-Volume is failing in this case on an Azure Disk mounted volumen, when called from within the container. I believe the CSI disk driver (https://github.com/kubernetes-sigs/azuredisk-csi-driver) attaches the network disk to the host, and then loops that to a volume .