Yihua Cao
Yihua Cao

Reputation: 21

Does windows container support to open/attach vhd file at runtime?

Want to open/attach virtual disk from vhd share inside a docker windows container based on mcr.microsoft.com/windows/server:ltsc2022, it throws "A virtual disk support provider for the specified file was not found". Does windows container support to open/attach vhd file at runtime?

Code used to OpenVirtualDisk is as below. [DllImport("virtdisk.dll", CharSet = CharSet.Unicode)] internal static extern long OpenVirtualDisk(ref VIRTUAL_STORAGE_TYPE virtualStorageType, string path, VirtualDiskAccessMask virtualDiskAccessMask, OPEN_VIRTUAL_DISK_FLAG fags, ref OPEN_VIRTUAL_DISK_PARAMETERS prameters, ref IntPtr handle);

Upvotes: 2

Views: 412

Answers (1)

Vinicius Apolinario
Vinicius Apolinario

Reputation: 449

Can you please provide more details on the environment you're running? To your question more specifically I think the ideal would be to mount the VHD file on the host and mount it when you run the container. However, I'm not sure you have a simple test/dev environment with Docker only or this is running on Kubernetes or something else. To mount a volume on Windows containers, you can use: docker run -v c:\ContainerData:c:\data:RO for read-only access docker run -v c:\ContainerData:c:\data:RW for read-write access docker run -v c:\ContainerData:c:\data for read-write access (default)

For more details, check out the docs page: https://learn.microsoft.com/virtualization/windowscontainers/manage-containers/persistent-storage

Upvotes: 0

Related Questions