I'm trying to add the Arial font to a Docker Windows image in Docker Desktop v4.13.1.
The arial.ttf file is in the folder Resources/fonts
This is in the Dockerfile:
COPY ./Resources/fonts /windows/fonts
RUN powershell -NoProfile -Command New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts' -name 'Arial (TrueType)' -value 'arial.ttf' -type STRING
When I try to built I get this error:
TrueType : The term 'TrueType' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:94 ... crosoft\Windows NT\CurrentVersion\Fonts -name Arial (TrueType) -value ... ~~~~~~~~ CategoryInfo : ObjectNotFound: (TrueType:String) [], CommandNot FoundException FullyQualifiedErrorId : CommandNotFoundException
If i remove the powershell command the image builds. When I run the powershell command inside the container it works too! But not in the Dockerfile...
CodePudding user response:
Your command is not valid. See the powershell.exe help for details.
powershell /?
From reading the examples directly from the help files, you end up here:
./Resources/fonts /windows/fonts
RUN powershell -NoProfile -Command {New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts' -name 'Arial (TrueType)' -value 'arial.ttf' -type STRING}
The command must be properly constructed, quoted, braced, etc., or placed in arguments to be executed.
EXAMPLES
PowerShell -PSConsoleFile SqlSnapIn.Psc1
PowerShell -version 2.0 -NoLogo -InputFormat text -OutputFormat XML
PowerShell -ConfigurationName AdminRoles
PowerShell -Command {Get-EventLog -LogName security}
PowerShell -Command "& {Get-EventLog -LogName security}"