Docker Recipe: Media Foundation on Windows Server Core

Applications, like Plex Media Server, rely on the Media Foundation Platform for access to codecs, hardware devices, and DirectX Video Acceleration. Media Foundation is built into consumer versions of Windows, but is an optional bolt on for Windows Server for obvious attack surface/footprint reasons.

Installing MF in optional environments like Server Core is typically easy enough. A simple PS> Install-WindowsFeature, a reboot, and you're done. Container authors, however, will struggle with Media Foundation for several reasons:

  1. Media Foundation packaging is marked with 'reboot required' metadata
  2. Component Based Servicing (CBS) respects this metadata and goes down the path of configuring the system for pending service operations (e.g. \WinSxS\pending.xml) to run at power on/off
  3. Of course, servicing the base image isn't a supported scenario, so the components involved (poqexec.exe) fail (e.g. NtFsControlFile failures in Windows::Rtl::TxfLogExpander::GetCurrentContainerCountMax) and CBS never gets to finish

The Media Foundation package authors clearly had a reason to mark this package as "reboot required" but that may have been before the advent of containers and the minimal subsystem within.

If you want to experiment with the Media Foundation Platform package in a container (unsupported), you will need to modify the package metadata to not require a reboot prior to installing the package.

Here's a contrived PowerShell example you can execute in your Dockerfile:

Get-ChildItem "$Env:SystemRoot\Servicing\Packages\*Media*.mum" |
ForEach-Object {
  (Get-Content $_) -replace 'required','no' | Set-Content $_
}

If you prefer to be explicit (recommended), you'll want to patch up:

  • Microsoft-Windows-Media-Format-Package~31bf3856ad364e35~amd64~~10.0.14393.0.mum
  • Microsoft-Windows-Server-Media-Foundation~31bf3856ad364e35~amd64~~10.0.14393.0.mum

Feel free to reach out if you run into any other snags. You can find me in the Windows Containers forum on MSDN or contact me using the links on the blog.