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

Just started playing around with Docker. To deploy a war on tomcat there seem to be two approaches:

  • Create image with java + tomcat + war embedded in the image
  • Have a base image with java + tomcat and then "inject" the war into the base image (through host volume mount, for example)
  • Approach 1:

  • Need to create one image for each build
  • Completely bundled solution
  • Due to the large image sizes, maintaining one image for each build and sharing the image for downstream deployment could become an issue
  • Approach 2:

  • Keep a base image in docker hub
  • Add war externally and run
  • Smaller distributable size (only war), but additional step that the deployment team needs to 'know' the name of image to run
  • Which of these approaches is typically used in production?


    If you want to deploy your code onto a docker orchestration service such as Google Container Engine, Amazon Container Service etc then option 1 is normally the only feasible solution as you don't have access to the host. Option 1 is also more scalable on docker orchestration systems as you can create multiple instances of your service on various docker hosts.

    However, I myself use option 2 for the reasons you have mentioned and because I manage scaling through auto-scaling groups using cloud formation which can provision instances with my war in the local store. Right now I don't think docker orchestration is mature enough for me to replace my external orchestration systems and if I have those systems setup then there is no point loosing the benefits of approach 2. However, when amazon allows us to connect ELBs directly to docker containers and makes a few more improvements I will seriously reconsider.

    Due to the large image sizes, maintaining one image for each build and sharing the image for downstream deployment could become an issue

    FYI Docker uses a diff based file system so as long as you are only changing the war file your image storage should not be an issue.

    链接地址: http://www.djcxy.com/p/24086.html

    上一篇: Ruby vs Java:为什么Java会让世界变得更快?

    下一篇: Docker:哪种方法更好? WAR嵌入在图像或基础图像+战争?