Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
157 views
in Technique[技术] by (71.8m points)

java - Correct way to deploy WAR files in docker image

What is the docker way to deploy java projects in a docker container?

Do I copy the war into webapps:

FROM jetty:9.2.10
MAINTAINER Me "[email protected]"
ADD ./target/*.war /var/lib/jetty/webapps/ROOT.war

or do I take the exploded war file:

FROM jetty:9.2.10
MAINTAINER Me "[email protected]"
ADD ./target/app-0.1.0.BUILD-SNAPSHOT /var/lib/jetty/webapps/ROOT

Normally one would deploy the sealed war file if it was a normal container, but with docker, that means pushing a 10-20MB file every time you make a small change whereas adding the exploded war would only push the difference - the .class file that has changed.

Are there any downsides to deploying the exploded war instead of the war file?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You should actually ALWAYS deploy the exploded .war.

There are two elements of speed to think about here:

  1. How fast is it to be able to push up your image to a container repository?

    and

  2. How quickly can a new instance of my container start serving requests? (important in an elastic-scaling environment)

The answer to both is the same: You are better off exploding the .war file when creating your container and NOT copying the .war file to it.

This has the following two very positive effects:

  1. It makes the differences between container versions much smaller, and so your upload time is less.
  2. It means that, when dynamically scaling to meet application demand, your new container instances don't have to unzip your .war file before they can start responding to requests.

For those of us burdened by slow-upload connections, it's also a great idea to use a CI server or even a cloud-hosted VM to build and push your docker images to dockerhub or another container registry. That way you can take advantage of gigabit-scale upload speeds.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...