microsoft / Windows-Containers

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

Reduce the bloat or at least provide us the tooling to be able to do it ourselves. #367

Closed ChrisMcKee closed 1 year ago

ChrisMcKee commented 1 year ago

Is your feature request related to a problem? Please describe. There was a great post a couple of years back ...

Shrinking the windows images down; but soon after an update was released for windows and the bloat returned never to be reduced again.

Describe the solution you'd like We have no way to debloat a windows container; you can't use docker-slim against windows containers or squash to reduce the layers and you can't export the image to tar to remove things that have no real place in a container used to wrap a dotnet application.

Either tooling or produce a base image with little to none of the stuff installed / pre-cached; and layer on the features; i.e. There's updates installed for tablet pc path and handwriting, text to speech etc which seems off.


Additional context

image

Name                         Size             Value
----                         ----             -----
C:\Windows\ADFS              0.04 MB          47104
C:\Windows\AppCompat         0.19 MB         203776
C:\Windows\apppatch          7.95 MB        8333952
C:\Windows\AppReadiness      0.00 MB
C:\Windows\assembly          884.08 MB    927025628
C:\Windows\Boot              26.55 MB      27836067
C:\Windows\Branding          4.66 MB        4883896
C:\Windows\diagnostics       0.76 MB         802089
C:\Windows\drivers           0.00 MB
C:\Windows\en-US             0.06 MB          59904
C:\Windows\Fonts             0.11 MB         111108
C:\Windows\Globalization     46.65 MB      48919168
C:\Windows\Help              0.88 MB         922196
C:\Windows\IME               108.15 MB    113402865
C:\Windows\INF               8.93 MB        9366620
C:\Windows\InputMethod       36.36 MB      38126462
C:\Windows\L2Schemas         0.00 MB
C:\Windows\LiveKernelReports 0.00 MB
C:\Windows\Logs              0.01 MB           5437
C:\Windows\Microsoft.NET     564.44 MB    591857702
C:\Windows\Migration         0.00 MB           3135
C:\Windows\OCR               0.21 MB         219754
C:\Windows\Panther           0.00 MB           4128
C:\Windows\PLA               0.65 MB         680405
C:\Windows\PolicyDefinitions 5.94 MB        6224591
C:\Windows\Prefetch          0.00 MB
C:\Windows\Provisioning      0.00 MB
C:\Windows\Registration      0.02 MB          22588
C:\Windows\RemotePackages    0.00 MB
C:\Windows\rescache          0.03 MB          28016
C:\Windows\Resources         1.96 MB        2058044
C:\Windows\SchCache          0.00 MB
C:\Windows\schemas           0.10 MB         105806
C:\Windows\security          1.43 MB        1500445
C:\Windows\ServiceProfiles   3.71 MB        3888908
C:\Windows\ServiceState      0.00 MB           4096
C:\Windows\servicing         77.69 MB      81468392
C:\Windows\Setup             0.00 MB             42
C:\Windows\SKB               3.58 MB        3757408
C:\Windows\Speech            102.80 MB    107797490
C:\Windows\Speech_OneCore    55.81 MB      58516716
C:\Windows\System            0.00 MB
C:\Windows\System32          1,020.35 MB 1069911533
C:\Windows\SystemResources   0.06 MB          59016
C:\Windows\SystemTemp        0.00 MB
C:\Windows\SysWOW64          366.96 MB    384785444
C:\Windows\Tasks             0.00 MB              6
C:\Windows\Temp              0.00 MB            102
C:\Windows\tracing           0.00 MB
C:\Windows\Vss               0.01 MB          12420
C:\Windows\WaaS              0.03 MB          28944
C:\Windows\Web               0.25 MB         262580
C:\Windows\WinSxS            2,534.30 MB 2657406656 [hard-links]
-- dism /Online /Cleanup-Image /AnalyzeComponentStore
Component Store (WinSxS) information:

Windows Explorer Reported Size of Component Store : 2.65 GB

Actual Size of Component Store : 2.65 GB

    Shared with Windows :  0 bytes
    Backups and Disabled Features : 2.58 GB
    Cache and Temporary Data : 75.29 MB
PS C:\Windows> Dism /online /Get-Packages

Deployment Image Servicing and Management tool
Version: 10.0.17763.3406

Image Version: 10.0.17763.4377

Packages listing:

Package Identity : Microsoft-OneCore-Containers-Guest-Package~31bf3856ad364e35~amd64~en-US~10.0.17763.1
State : Installed
Release Type : Language Pack
Install Time : 5/5/2023 11:35 AM

Package Identity : Microsoft-OneCore-Containers-Guest-Package~31bf3856ad364e35~amd64~~10.0.17763.1
State : Installed
Release Type : Feature Pack
Install Time : 5/5/2023 11:35 AM

Package Identity : Microsoft-Windows-FodMetadata-Package~31bf3856ad364e35~amd64~~10.0.17763.1
State : Installed
Release Type : Feature Pack
Install Time : 9/15/2018 9:05 AM

Package Identity : Microsoft-Windows-Foundation-Package~31bf3856ad364e35~amd64~~10.0.17763.1
State : Installed
Release Type : Foundation
Install Time : 9/15/2018 7:13 AM

Package Identity : Microsoft-Windows-LanguageFeatures-Basic-en-us-Package~31bf3856ad364e35~amd64~~10.0.17763.1
State : Installed
Release Type : OnDemand Pack
Install Time : 9/15/2018 9:05 AM

Package Identity : Microsoft-Windows-LanguageFeatures-Handwriting-en-us-Package~31bf3856ad364e35~amd64~~10.0.17763.1
State : Installed
Release Type : OnDemand Pack
Install Time : 9/15/2018 9:05 AM

Package Identity : Microsoft-Windows-LanguageFeatures-OCR-en-us-Package~31bf3856ad364e35~amd64~~10.0.17763.1
State : Installed
Release Type : OnDemand Pack
Install Time : 9/15/2018 9:06 AM

Package Identity : Microsoft-Windows-LanguageFeatures-Speech-en-us-Package~31bf3856ad364e35~amd64~~10.0.17763.1
State : Installed
Release Type : OnDemand Pack
Install Time : 9/15/2018 9:05 AM

Package Identity : Microsoft-Windows-LanguageFeatures-TextToSpeech-en-us-Package~31bf3856ad364e35~amd64~~10.0.17763.1
State : Installed
Release Type : OnDemand Pack
Install Time : 9/15/2018 9:05 AM

Package Identity : Microsoft-Windows-Security-SPP-Component-SKU-ServerDatacenter-GVLK-Package~31bf3856ad364e35~amd64~~10.0.17763.1
State : Installed
Release Type : Feature Pack
Install Time : 9/15/2018 9:08 AM

Package Identity : Microsoft-Windows-Server-LanguagePack-Package~31bf3856ad364e35~amd64~en-US~10.0.17763.1
State : Installed
Release Type : Language Pack
Install Time : 9/15/2018 9:05 AM

Package Identity : Microsoft-Windows-ServerCore-Package~31bf3856ad364e35~amd64~~10.0.17763.1
State : Installed
Release Type : Feature Pack
Install Time : 9/15/2018 7:13 AM

Package Identity : Microsoft-Windows-ServerCore-SKU-Foundation-Package~31bf3856ad364e35~amd64~~10.0.17763.1
State : Installed
Release Type : Feature Pack
Install Time : 9/15/2018 7:13 AM

Package Identity : Microsoft-Windows-TabletPCMath-Package~31bf3856ad364e35~amd64~~10.0.17763.1
State : Installed
Release Type : OnDemand Pack
Install Time : 9/15/2018 9:06 AM

Package Identity : OpenSSH-Client-Package~31bf3856ad364e35~amd64~~10.0.17763.1
State : Installed
Release Type : OnDemand Pack
Install Time : 9/15/2018 9:06 AM

Package Identity : Package_for_DotNetRollup~31bf3856ad364e35~amd64~~10.0.4038.3
State : Installed
Release Type : Update
Install Time : 5/5/2023 11:36 AM

Package Identity : Package_for_RollupFix~31bf3856ad364e35~amd64~~17763.4377.1.12
State : Installed
Release Type : Security Update
Install Time : 5/5/2023 11:45 AM

Package Identity : Package_for_ServicingStack_4121~31bf3856ad364e35~amd64~~17763.4121.1.1
State : Installed
Release Type : Security Update
Install Time : 5/5/2023 11:35 AM
PS C:\> dism /Online /Get-Capabilities

Deployment Image Servicing and Management tool
Version: 10.0.17763.3406

Image Version: 10.0.17763.4377

Capability listing:
Capability Identity : Language.Basic~~~en-US~0.0.1.0
State : Installed

Capability Identity : Language.Handwriting~~~en-US~0.0.1.0
State : Installed

Capability Identity : Language.OCR~~~en-US~0.0.1.0
State : Installed

Capability Identity : Language.TextToSpeech~~~en-US~0.0.1.0
State : Installed

Capability Identity : MathRecognizer~~~~0.0.1.0
State : Installed

Capability Identity : OpenSSH.Client~~~~0.0.1.0
State : Installed
akarshm commented 1 year ago

Hey Chris, we made a lot of improvements in Windows containers to reduce their size. You can read about it in our blog for months Jan 2023, Feb 2023, and May 2023. We pruned almost everything that was not required to be present in the container image. Is there anything specific you wanted to point us to?

ChrisMcKee commented 1 year ago

https://devblogs.microsoft.com/dotnet/we-made-windows-server-core-container-images-40-smaller/ the uncompressed container sizes when this post was written was around 2gig with FX.

I was trying to work out how that work seemingly vanished into the ether leaving us pulling 5+ gig images from the msft container repo (which for added pleasure seems to cap connections at 6mbps)

Hard to workout how to improve this from the outside as none of the construction is public; Vs the options when creating amis/VMware images.