I did not find any Elasticsearch docker images for windows. I tried to build my own jdk11 image and an elasticsearch 7.1.1 on top of that. The problem is that in elasticsearch 7.1.1 the JAVA_HOME is set in elasticsearch.bat, so it overrides the JAVA_HOME of the jdk image.
My jdk11 Dockerfile looks like this:
FROM mcr.microsoft.com/powershell:nanoserver
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop';"]
COPY /jdk-11.0.3_windows-x64_bin.zip jdk.zip
ENV JAVA_HOME=C:\\jdk-11 \
PATH=C:\\jdk-11\\bin;C:\\windows\\system32${PATH}
RUN Expand-Archive -Path c:/jdk.zip -DestinationPath c:/ ;\
Remove-Item c:/jdk.zip -Force
My elasticsearch 7.1.1 dockerfile looks like this:
FROM jdk11:forelastic
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop';"]
COPY /elasticsearch-7.1.1-windows-x86_64.zip c:\\elasticsearch.zip
RUN Expand-Archive -Path c:/elasticsearch.zip -DestinationPath c:/ ;\
Rename-Item c:/elasticsearch-7.1.1 c:/elasticsearch ;\
Remove-Item c:/elasticsearch.zip -Force ;\
New-Item -Path c:/temp -ItemType "directory"
SHELL ["cmd", "/S", "/C"]
ENV ES_PATH_CONF='c:\\\\elasticsearch\\\\config'
RUN del c:\elasticsearch\config /F /S /Q
WORKDIR c:/elasticsearch/bin
CMD ["cmd", "/C","elasticsearch.bat"]
The images are built. When I try to run the elasticsearch container I get this message:
"could not find java in JAVA_HOME or bundled at C:\elasticsearch\jdk"
I took a closer look at elasticsearc 7.1.1 elasticsearch.bat and at the end i find these commands:
%JAVA% %ES_JAVA_OPTS% -Delasticsearch -Des.path.home="%ES_HOME%" -Des.path.conf="%ES_PATH_CONF%" -Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" -Des.distribution.type="%ES_DISTRIBUTION_TYPE%" -Des.bundled_jd="%ES_BUNDLED_JDK%" -cp "%ES_CLASSPATH%" "org.elasticsearch.bootstrap.Elasticsearch" !newparams!
Should i build the elasticsearch image with a modified elasticsearch.bat or is there a more graceful way to go?
PS: I am running these in Windows 10(1809). Earlier distributions of windows 10 did not support it, but it is fixed with fixes on symbolic links.