Docker: Which approach is better? War embedded in the image or image base + war?

Just started playing with Docker. There are two approaches to deploying a war with tomcat:

  • Create an image using java + tomcat + war embedded in the image
  • You have a base image with java + tomcat, and then "enter" the war into the base image (for example, using a host mount).

Approach 1:

  • You must create one image for each assembly.
  • Fully Embedded Solution
  • Due to the large image size, supporting one image for each assembly and sharing the image for later deployment can be a problem.

Approach 2:

  • Saving a basic image in a docker hub
  • Add war from the outside and run
  • Smaller distribution kit (war only), but an additional step that the deployment team must β€œknow” the name of the image to run

Which of these approaches is commonly used in manufacturing?

+7
java docker tomcat
source share
1 answer

If you want to deploy your code in a docker mapping service such as the Google Container Engine, Amazon Container Service, etc., then option 1 is usually the only possible solution since you do not have access to the host. Option 1 is also more scalable in docker orchestration systems, as you can create multiple instances of your service on different docker hosts.

However, I myself use option 2 for the reasons you mentioned, and because I control the scaling through auto-scaling groups using cloud formations that can provide instances of my war in the local store. Now I don’t think that docker orchestration is mature enough for me to replace my external orchestration systems, and if I have these systems, then it makes no sense to lose the advantages of approach 2. However, when amazon allows us to directly connect ELB to docker containers and will bring some more improvements, I’m seriously changing my mind.

Due to the large size of the images, supporting one image for each assembly and sharing the image for later deployment can be a problem

FYI Docker uses a diff-based file system, so as long as you change only the war file, your image storage should not be a problem.

+3
source share

All Articles