Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  1. Create image with java + tomcat + war embedded in the image
  2. 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?

like image 328
gammay Avatar asked Dec 31 '14 09:12

gammay


1 Answers

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.

like image 51
Usman Ismail Avatar answered Sep 20 '22 12:09

Usman Ismail