Search code examples
dockerspring-bootdockerfile

is it a good practice to put a war file image into docker containers?


I am new to docker. I have a Spring-boot application which I want to deploy and run using docker. Is it a good practice to put war file images in the container or it is better to put jar ones? why?

P.S. Once I read that it is better to "make jars , not wars" :-) but do not know the reason behind it.


Solution

  • One of the main reasons for building a docker image for your application is to provide an artefact that people can run without installing and managing external software dependencies (like an app server to run a war file).

    From a container user perspective, it makes no difference whether you package your code in a jar or a war file or as a fortran binary. All they do is run a container image.

    From your perspective, of doing the Docker build and config management, the packaging of a jar file and copying into a container would be a simpler solution than trying to setup and configure an app server for packaging, then deploying each release into the app server. That being said, users would probably prefer the more complete app server solution, because that may be easier for them the run the application.

    See Ohmens answer for some more technical components of the java build process