testing
testing

Reputation: 20289

Install Erlang in docker image on Windows Server 2019 build machine

I'm trying to install RabbitMQ in my custom docker image. For RabbitMQ I need Erlang and I install it in the docker file like this:

RUN powershell -Command Start-Process -Wait -FilePath C:\otp_win64_23.3.exe -ArgumentList /S;

Building the docker image works and when I run it as container I get the following main error:


ERLANG_HOME not set correctly.


Please either set ERLANG_HOME to point to your Erlang installation or place the RabbitMQ server distribution in the Erlang lib folder.

So the environment variable is not correctly set and the bin folder is also missing. Some installation artefacts can be found in C:\Program Files\erl-23.2 though ... This approach had worked three months before and now doesn't work anymore and I don't know what changed.

The image is built on Windows Server 2019 and has a Windows Server 2019 as base image. When I build on my local developer machine (Windows 11) with Docker Desktop it works, but not on the build server (Mirantis Container Runtime). So what is different?

This is a minimal example of my DockerFile:

FROM mcr.microsoft.com/windows/servercore:ltsc2019

HEALTHCHECK --interval=10s \
 CMD powershell -command \
    try { \
     $response = iwr http://localhost:8080/base/version -UseBasicParsing; \
     if ($response.StatusCode -eq 200) { return 0} \
     else {return 1}; \
    } catch { return 1 }

ADD binaries/jdk-11.0.2-win jdk-11.0.2
ADD binaries/rabbitmq_server-3.8.14 rabbitmq_server-3.8.14
ADD binaries/otp_win64_23.3.exe otp_win64_23.3.exe
ADD binaries/python-2.7.11.amd64.msi python-2.7.11.amd64.msi

RUN powershell -Command Start-Process -Wait -FilePath C:\\otp_win64_23.3.exe -ArgumentList /S;
RUN powershell -Command Start-Process msiexec.exe -Wait -ArgumentList '/I C:\python-2.7.11.amd64.msi /quiet  ALLUSERS=1 TARGETDIR=C:\python27 ADDLOCAL=ALL'

RUN for /d %f in ("C:\rabbitmq_server-*") do @mklink /D C:\rabbitmq_server "%f" && exit
ADD config/rabbitmq/init-rabbitmq.ps1 /mydir/init-rabbitmq.ps1

ADD /testerlang.ps1 /mydir/testerlang.ps1

ARG JAVA_HOME="C:\jdk-11.0.2"
ENV JAVA_HOME="C:\jdk-11.0.2"                                                      
ARG ERLANG_HOME="C:\Program Files\erl-23.3"
ENV ERLANG_HOME="C:\Program Files\erl-23.3"

RUN setx path "%path%;C:\rabbitmq_server\sbin;C:\python27"

WORKDIR C:\\mydir

CMD ["powershell.exe", "./testerlang.ps1"]

testerlang.ps1

C:\rabbitmq_server\sbin\rabbitmq-service.bat install
C:\rabbitmq_server\sbin\rabbitmq-service.bat start
Copy-Item "C:\Windows\system32\config\systemprofile\.erlang.cookie" -Destination "C:\Users\ContainerAdministrator\.erlang.cookie" -Force
C:\mydir\init-rabbitmq.ps1
C:\rabbitmq_server\sbin\rabbitmq-service.bat stop
C:\rabbitmq_server\sbin\rabbitmq-service.bat start

ping -t localhost  > $null

I've tried multiple things (different machine, different commands, use of chocolatey ...) but I never found out what the reason for the different behavior is. For me it looks like a permission thing, but I don't really know.

Upvotes: 0

Views: 32

Answers (1)

testing
testing

Reputation: 20289

Not the real solution but a workaround:

Until KB5044277 of the Windows Server 2019 image everything works fine. Since KB5046615 Microsoft changed something, which breaks the Erlang installation. One assumption is that the Visual C ++ Redistributable, which comes with the installer, causes somehow the problem.

Changing the docker file to this fixes this for now:

FROM mcr.microsoft.com/windows/servercore:1809-KB5044277-amd64

Upvotes: 0

Related Questions