简体   繁体   中英

RabbitMQ is slow to start inside Windows Docker Container

Here is my dockerfile

 FROM microsoft/windowsservercore

 # rabbitmq version used in download url and to rename folder extracted from 
 zip file
ENV rabbitmq_version "3.6.11"

#download erlang and RabbitMQ
ADD "http://erlang.org/download/otp_win64_19.3.exe" "erlang_install.exe"
ADD "https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.11/rabbitmq-
server-windows-3.6.11.zip" "rabbitmq.zip"

# erlang will install to this location and rabbitmq will use this 
environment variable to locate it
ENV ERLANG_HOME c:\\erlang

# setup powershell options for RUN commands
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; 
$ProgressPreference = 'SilentlyContinue';"]

# install erlang using silent install option, and remove installer when done
RUN Start-Process -Wait -FilePath .\erlang_install.exe -ArgumentList /S, 
/D=$env:ERLANG_HOME ; \
Remove-Item -Force erlang_install.exe

# extract rabbitmq, and remove zip file when done
RUN Expand-Archive -Path .\rabbitmq.zip -DestinationPath "c:\\" ; \
Remove-Item -Force rabbitmq.zip

# remove version from rabbitmq folder name
RUN Rename-Item c:\rabbitmq_server-$env:rabbitmq_version c:\rabbitmq

# enable managment plugin
RUN c:\rabbitmq\sbin\rabbitmq-plugins.bat enable rabbitmq_management --
offline


# tell rabbitmq where to find our custom config file
ENV RABBITMQ_CONFIG_FILE "c:\rabbitmq"
RUN ["cmd", "/c", "echo [{rabbit, [{loopback_users, []}]}].> 
c:\\rabbitmq.config"]

EXPOSE 15672
EXPOSE 5672

# run server when container starts - container will shut down when this 
process ends
CMD "c:\rabbitmq\sbin\rabbitmq-server.bat"

When the container starts on my windows 10 machine it takes anywhere between 5-10 minutes to see that the actual broker started in the logs. I also cant hit the management portal and no apps can connect until the broker starts. Is there any way to get the broker to start faster? It doesnt do this on linux containers

When the container starts on my windows 10 machine it takes anywhere between 5-10 minutes to see that the actual broker started in the logs.

It appears that you are installing Erlang from scratch every time your container starts up ( erlang_install.exe ).

What Linux container did you try that does not exhibit this issue? Does it have RabbitMQ installed out-of-the-box? Can you use a Windows container with RabbitMQ pre-installed, or create a container image yourself that you can then re-use?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM