microsoft / Windows-Containers

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

[BUG] Problems Installing Fonts Features in Windows Server 2019 Container. #355

Closed boxoky closed 3 months ago

boxoky commented 1 year ago

Describe the bug Hi everyone, while I was working with Windws Containers and trying to install Fonts Feature, I came across this Post https://techcommunity.microsoft.com/t5/itops-talk-blog/adding-optional-font-packages-to-windows-containers/ba-p/3559761, the problem occurs when I execute the "InstallFonts.cmd" file, to be more exact, in the las line "dism /online /enable-feature /featurename:ServerCoreFonts-NonCritical-Fonts-UAPFonts /Source:O:\ /LimitAccess" the terminal throws me an error message:

C:\>dism /online /enable-feature /featurename:ServerCoreFonts-NonCritical-Fonts-UAPFonts /Source:O:\ /LimitAccess

Deployment Image Servicing and Management tool
Version: 10.0.17763.3406

Image Version: 10.0.17763.4131

Enabling feature(s)
[ 0.1% ]
[ 1.1% ]
[====== 10.7% ]
[======= 12.1% ]
[======= 13.5% ]
[======== 15.0% ]
[========= 16.4% ]
[========== 17.8% ]
[=========== 19.2% ]
[============ 20.7% ]
[============ 22.1% ]
[============= 23.5% ]
[============== 25.0% ]
[=============== 26.4% ]
[================ 27.8% ]
[================ 29.2% ]
[================= 30.0% ]
[==========================100.0%==========================]

Error: 0x800f081f

The source files could not be found.
Use the "Source" option to specify the location of the files that are required to restore the feature. For more information on specifying a source location, see http://go.microsoft.com/fwlink/?LinkId=243077.

The DISM log file can be found at C:\Windows\Logs\DISM\dism.log

To Reproduce My Dockerfile (I have omitted the name of the published project.):

FROM mcr.microsoft.com/dotnet/framework/aspnet

ARG SHARE_PW=

# <> INSTALACION DE FEATURES DE GESTION PARA IIS <>
RUN powershell -NoProfile -Command \
    Install-WindowsFeature Web-Mgmt-Tools  

# <> INSTALACION DE FEATURES DE DESARROLLO <>
RUN powershell -NoProfile -Command \
    Install-WindowsFeature Web-App-Dev; \
    Install-WindowsFeature Web-Net-Ext45; \
    Install-WindowsFeature Web-AppInit; \
    Install-WindowsFeature Web-ASP; \
    Install-WindowsFeature Web-Asp-Net45; \
    Install-WindowsFeature Web-CGI; \
    Install-WindowsFeature Web-ISAPI-Ext; \
    Install-WindowsFeature Web-ISAPI-Filter; \
    Install-WindowsFeature Web-Includes; \
    Install-WindowsFeature Web-WebSockets; 

# <> INSTALACION DE FEATURES DE SEGURIDAD DE IIS <>
RUN powershell -NoProfile -Command \
    Install-WindowsFeature Web-Security; \
    Install-WindowsFeature Web-Filtering; \
    Install-WindowsFeature Web-Basic-Auth; \
    Install-WindowsFeature Web-Client-Auth; \
    Install-WindowsFeature Web-Digest-Auth; \
    Install-WindowsFeature Web-Cert-Auth; \
    Install-WindowsFeature Web-IP-Security; \
    Install-WindowsFeature Web-Url-Auth; \
    Install-WindowsFeature Web-Windows-Auth; 

RUN powershell -NoProfile -Command  \
    Set-Culture -CultureInfo es-MX ; \
    powershell -NoProfile -Command \
    Set-WinSystemLocale es-MX; \
    powershell -NoProfile -Command \
    Set-WinHomeLocation -GeoId 166; \
    powershell -NoProfile -Command \
    Set-WinUserLanguageList -LanguageList es-MX -Force; 
RUN powershell -NoProfile -Command \
    iisreset

# <---------->  INSTALACION/HABILITAR EL USO DE FUENTES <---------->
COPY InstallFonts.cmd /
RUN C:\InstallFonts.cmd

# <----------> COPIANDO EL PROYECTO YA COMPILADO <---------->
COPY ./project /inetpub/wwwroot/nameOfTheProject

# <----------> CREACION Y CONFIGURACION DE LA PUBLICACION DEL APLICATIVO EN IIS <---------->.
RUN powershell -NoProfile -Command \
    Import-module IISAdministration; \
    New-WebApplication -Name "nameOfTheProject
" -Site '"Default Web Site"' -PhysicalPath "C:\inetpub\wwwroot\nameOfTheProject
"

# <----------> EXPOSICION DEL PROYECTO <---------->
EXPOSE 80

Expected behavior I am expecting a successful build of my container to install custom Fonts.

Configuration: I am using : ==> Windows Server 2019 1809 as Host MAchine to create Containers. ==> Mirantis CRI (Docker Enterprise edition). ==> Docker version: 20.10.14, build b7d1bc9

vrapolinario commented 1 year ago

Thanks for opening the issue here @boxoky. I have assigned it to @fady-azmy-msft. Fady: Not sure you're the right person but you might be able to delegate if that's the case.

On a separate note to @boxoky: You might want to look into multi-stage builds to reduce the final size of your image, since you have so many installation steps in it.

boxoky commented 1 year ago

Okay, I get it. Thank you for your support. I will be waiting some feedback. To be honest, I commented the last line:

dism /online /enable-feature /featurename:ServerCoreFonts-NonCritical-Fonts-MinConsoleFonts /Source:O:\ /LimitAccess
dism /online /enable-feature /featurename:ServerCoreFonts-NonCritical-Fonts-Support /Source:O:\ /LimitAccess
dism /online /enable-feature /featurename:ServerCoreFonts-NonCritical-Fonts-BitmapFonts /Source:O:\ /LimitAccess
dism /online /enable-feature /featurename:ServerCoreFonts-NonCritical-Fonts-TrueType /Source:O:\ /LimitAccess
REM dism /online /enable-feature /featurename:ServerCoreFonts-NonCritical-Fonts-UAPFonts /LimitAccess

And everything works, but, I don't know to what extent it is important or detrimental. And the installation process of the Fonts in my Dockerfile is :

# <---------->  INSTALACION/HABILITAR EL USO DE FUENTES <---------->
COPY InstallFonts.cmd /
RUN C:\InstallFonts.cmd
COPY LoadFonts.ps1 /
RUN powershell -NoProfile -Command \
    C:\LoadFonts.ps1;
RUN powershell -NoProfile -Command \
    Remove-Item C:\InstallFonts.cmd; \
    Remove-Item C:\LoadFonts.ps1;

# <----------> INSTALACION DE LAS FUENTES NECESARIAS PARA EL APLICATIVO <---------->
COPY fonts /fonts
# <> VERDANA <>
RUN powershell -NoProfile -Command \
   copy-item C:\fonts\verdana\verdana.ttf c:\windows\fonts\; \
   Set-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts' -name 'Verdana' -value 'verdana.ttf' -type STRING; 
# <> ARIAL <>
RUN powershell -NoProfile -Command \
   copy-item C:\fonts\Arial\arial.ttf c:\windows\fonts\; \
   Set-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts' -name 'Arial' -value 'arial.ttf' -type STRING; 
# <> TAHOMA <>
RUN powershell -NoProfile -Command \
   copy-item C:\fonts\Tahoma\tahoma.ttf c:\windows\fonts\; \
   Set-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts' -name 'Tahoma' -value 'tahoma.ttf' -type STRING;
RUN powershell -NoProfile -Command \
    Remove-Item C:\fonts -Recurse; 

I know that you have to run the "LoadFonts.ps1" file until the Container is running, but all attempts fail using some CMD or ENTRYPOINT instruction, and running this file in the build stage is how I was able to install some Fonts.

And the logs describing the lack of installation of some fonts, all disappear, and the installation of the Fonts (Arial, Verdana and Tahoma) and the generation process of the reports were successful. But, in my opinion, I could be wrong, and it is better to wait for some feedback.

And, regarding the last tip, you are absolutely right, I need to decrease the size of this image(s) to be more efficient. These are my first steps using Windows Container, and using-multi stage build and/or using some base image with all those intallation will make a straightforward way to drive it.

Thanks again @vrapolinario and the Microsoft team enrolled in it.

fady-azmy-msft commented 1 year ago

Hey @boxoky, we're looking into this (internal tracking #44585462).

microsoft-github-policy-service[bot] commented 1 year ago

This issue has been open for 30 days with no updates. @fady-azmy-msft, please provide an update or close this issue.

microsoft-github-policy-service[bot] commented 1 year ago

This issue has been open for 30 days with no updates. @fady-azmy-msft, please provide an update or close this issue.

cjwilson1 commented 1 year ago

I have the same issue.

The last line of your example:

dism /online /enable-feature /featurename:ServerCoreFonts-NonCritical-Fonts-UAPFonts /LimitAccess

From the link: Adding optional font packages to Windows containers ((https://techcommunity.microsoft.com/t5/itops-talk-blog/adding-optional-font-packages-to-windows-containers/ba-p/3559761))

I get the same error as the original poster of this issue:

The source files could not be found. Use the "Source" option to specify the location of the files that are required to restore the feature. For more information on specifying a source location, see http://go.microsoft.com/fwlink/?LinkId=243077.

Is there an update on this error?

I verified with our I.T. dept that the host Window Server 2019 where I am copying the file from (vis dism) had all of its updates installed.

axel-stronzik commented 1 year ago

I also have the same issue.

fady-azmy-msft commented 1 year ago

I don't have any updates to share on this yet, we're still looking into this.

pkinausleap commented 1 year ago

I also have the same issue.

microsoft-github-policy-service[bot] commented 1 year ago

This issue has been open for 30 days with no updates. @fady-azmy-msft, please provide an update or close this issue.

BenHesketh21 commented 1 year ago

I had this exact problem recently and all I had to do was apply windows updates on the host and the problem went away, that might not solve anyone's problem in here but I just thought I'd say because it took a while to spot it because we were running the docker build on pipeline agents and I didn't spot the agents needed windows updates until I had to update the agents image.

shurick81 commented 1 year ago

Here's results of some our tests of enabling these 5 features on mcr.microsoft.com/windows/servercore/iis image using Azure DevOps pipeline agent (vmImage: windows-2022):

image

shurick81 commented 1 year ago

looks like there is a correlation between the host where you run it and result?

mmgil commented 9 months ago

I also have the same issue.

evan-scales commented 8 months ago

I have the same issue

mittalmaster commented 6 months ago

I found out the solution of it simply just copy the required font from your local C:\Windows\Fonts to Windows Container C:\Windows\Fonts or you can make one folder in your solution with required font and just copy it After that just register it by using reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "FontName (TrueType)" /t REG_SZ /d FontName.ttf /f command replace FontName with your font name

restart your container it will work

microsoft-github-policy-service[bot] commented 5 months ago

This issue has been open for 30 days with no updates. @fady-azmy-msft, please provide an update or close this issue.

microsoft-github-policy-service[bot] commented 4 months ago

This issue has been open for 30 days with no updates. @fady-azmy-msft, please provide an update or close this issue.

ntrappe-msft commented 3 months ago

@viniciusl-msft will be publishing updates on this soon

michbern-ms commented 3 months ago

Our revised documentation is now posted: Add optional font packages to Windows containers | Microsoft Learn

Please take a look - as far as we know, this resolves the issue based on our testing.