microsoft / Windows-Containers

Welcome to our Windows Containers GitHub community! Ask questions, report bugs, and suggest features -- let's work together.
MIT License
385 stars 60 forks source link

Usage of DISM fails inside container due to missing device driver #494

Open JensNordenbro opened 2 months ago

JensNordenbro commented 2 months ago

Describe the bug Running 'dism /mount-wim /wimfile:"winpe.wim" /mountdir:"c:\MOUNT_DIR" /index:1' inside a container such as mcr.microsoft.com/windows/server:ltsc2022 does not work regardless of isolation mode:

To Reproduce image

Expected behavior It should just work. DISM seems to need WimMount driver and the driver is present inside the Docker image:

image

However I cannot find it to be installed using 'sc query type=driver'.

Configuration:

Additional context We tried to mount the folder outside container and Docker volume mount it into the container however it does not work for us.

(It is ok if it only works in hyper-V mode as far as I am concerted. I can run in any mode. ) (Maybe there is some argument that can be used to share the HOST driver?)

JensNordenbro commented 2 months ago

Also tried DISM from ADK-installation with the same result: image

ntrappe-msft commented 2 months ago

@JensNordenbro Hi, I'll try to repro this Issue. In the meantime, can you explain what you're trying to do? If you're trying to mount a volume with files you'll have to do that when you start up the container, not while in it.

ntrappe-msft commented 2 months ago

Quick note: I'll be slow to respond this week because of Build but I'll repro it as soon as I can.

JensNordenbro commented 2 months ago

Hi @ntrappe-msft !

I have also tried to mount the wim file outside the container (see text) and volume mount it but using this mount inside the container leads to crashes when doing further dism operations on that volume.

Inside the container, try to do something like "DISM.exe /image:"c:\mount" /Add-Driver /ForceUnsigned /DriverName:"C:\Drivers\1.inf" /DriverName:"C:\Drivers\2.inf" /DriverName:"C:\Drivers\3.inf"" or similar from https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/what-is-dism?view=windows-11

WE can survive not being able to mount a file as folder inside the container as long as the following DISM commands would work, inside the container. I do think it is a bit strange that this is not possible at least inside a Hyper-V backed container where the WM could host all drivers / services need for DISM.

JensNordenbro commented 1 month ago

Any chance to try this out @ntrappe-msft ?

ntrappe-msft commented 1 month ago

@JensNordenbro Hi, sorry for the delay. My backlog is too long right now so I'm going to triage this to another engineer.

ntrappe-msft commented 1 month ago

Spoke to the other engineers today. What you're trying to do is currently not supported. You're probably encountering issues due to two things: (A) the container can only see a few drivers on the host, wimmount.sys is likely one it cannot and (B) the operation you're trying to do would need to install a driver in a container which isn't permitted.

It is possible to enable this scenario but we'd need more information about your use case. Could you explain what you're trying to do with winpe.wim and the impact of this blocker on your work?

Thanks!

madspaulsen commented 1 month ago

Hi, my team would like to see this issue resolved also :) We're doing customized Windows images (Win10 and Server) and we're currently trying to migrate our old process into a Github workflow. We're starting from a Windows OPK (OEM Pre-installation Kit) which is pulled into the build runner where the image is mounted and we apply various customizations and finally publish a new, modified image. Or, that is what we want to do..

On our build runners (Windows in docker containers) we hit the same issue that we can't mount the Windows images (dism /mount-image /imagefile:...) and we're currently blocked by this: DismException: The image could not be mounted because the wimmount.sys driver is not installed on this machine. To fix this error, install the wimmount.sys driver.”

JensNordenbro commented 1 month ago

We are doing customized Windows 10 Iot Enterprise images. We want a reliable build environment, always reproducable, using containers.

I do not understand why hyper-v containers would not be able to pick this up quite easilly. In The VM you could add more drivers (command line option perhaps) and suddenly we could mount the wim inside the machine. This is all software so having to amount from the host seems wrong although tolerable.

bewster commented 2 weeks ago

I to have ran into this issue - got excited about the idea to try containerisation to maintain our Windows 10 IoT Enterprise Images.

Had hoped I could bypass the "run as admin" on dev machine requirement to mount and work with the WIM files.