Currently I'm testing with Microservices and Docker-Container. And during my last try with a Micronaut-Server I saw differences between the start-up-time for starting local (cmd) and starting with Docker. But what made me curios, is the fact that the Container was much faster.
I'm creating a runnable jar (more precisely a shadowjar - not sure what the exact difference is) with Gradle. Then I build a Docker-Image with that jar file.
The start command for both is the same (see the Dockerfile below):
java -jar micronaut.jar
During my search for a reason for that I found this question which is also about performance of Docker-Container, but the conclusion was more, that the Container should be slightly slower, not faster.
My Dockerfile:
FROM adoptopenjdk/openjdk11-openj9:jdk-11.0.1.13-alpine-slim
COPY build/libs/*.jar micronaut.jar
EXPOSE 8080
CMD java -jar micronaut.jar
and the docker command:
docker run -p 9999:9999 -it --name dokuserver pge/dokuserver:0.1
I expected that the start-up-time would be the same oder a bit slower for the container but actually the time is.
- Local: 4000-5000ms
- Docker: ~2500ms
I tried several times but the outcome ist always nearly the same.
I'm working on a Win10 PC with DockerDesktop (Docker 19.03.1), IntelliJ and Gradle (5.5.1) and used the IntelliJ-Terminal and the windows-cmd for the local start.
I'm no an expert in Docker or the things which happens closer to the hardware so I couldn't find an answer for this speed difference. So I'm asking you:
What could cause that?