Perl installation fails in docker

I am trying to install ActivePerl in a Windows docker image based on mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019 and it fails like this:

PS C:\TEMP> powershell -Command "& $([scriptblock]::Create((New-Object Net.WebClient).DownloadString('https://platform.activestate.com/dl/cli/install.ps1'))) -activate-default ActiveState/Perl-5.32"
At line:1 char:1
+ & # Copyright 2019 ActiveState Software Inc. All rights reserved.  
+ ~
Missing expression after '&' in pipeline element.
At line:1 char:66
+ & # Copyright 2019 ActiveState Software Inc. All rights reserved.  
+                                                                  ~ 
Unexpected token '
' in expression or statement.
At line:12 char:56
+     [Parameter(Mandatory=$False)][string]$b = 'release'
+                                                        ~
Missing closing ')' in expression.
At line:24 char:55
+     ,[Parameter(Mandatory=$False)][string]$activate = "
+                                                       ~
The string is missing the terminator: ".
At line:20 char:6
+     ,[Parameter(Mandatory=$False)]
+      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected attribute 'Parameter'.
At line:21 char:9
+         [ValidateScript({[IO.Path]::GetExtension($_) -eq '.exe'})]
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected attribute 'ValidateScript'.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingExpression
 

Is there anything I can do to fix the issue?

@giallu Thanks for posting, the team will look into this and advise accordingly.
Regards

Hi @giallu, we use the state tool internally in Windows containers but we install it slightly differently. The one-line install script is best suited for interactive installs. In a Dockerfile, you can install the state tool like this:

# escape=`

# Windows Server 2019
FROM mcr.microsoft.com/windows/servercore:ltsc2019
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

# Change registry to turn off Windows Advanced Threat Protection
RUN ("Set-ItemProperty -Path 'HKLM:SOFTWARE\Policies\Microsoft\Windows Advanced Threat Protection' -Name 'ForceDefenderPassiveMode' -Value '1' -Type 'DWORD'")

SHELL ["cmd", "/S", "/C"]

# Install the state tool
ADD https://platform.activestate.com/dl/cli/install.ps1 C:\Temp\install.ps1
RUN powershell C:\Temp\install.ps1 -n -t C:\ActiveState

Hope this is useful for you.

Shaun.

1 Like

Thanks Shaun, this is a step in the right direction for me, but it seems Iā€™m quickly getting into some rabbit hole :slight_smile:

In fact, I need a Perl working installation in this docker image as a prerequisite for building Qt, so now I need to understand how to use the state tool to achieve this.

Off to read some more docs!