Running Apache Tomcat in Windows Containers
If you're using Windows containers, check out WinDocks' latest support for Java and Tomcat.
Join the DZone community and get the full member experience.Join For Free
windocks is a port of docker’s open source to windows, supporting all editions of windows 8, windows 10, windows server 2012, and windows server 2016, and now including a new “base” windows container (similar to docker’s scratch container for linux). the new windows container is designed to support “container ready” executables, and works great with tomcat, jetty, nginx, and node.js.
in this article, we’ll look at windocks' new support for java and tomcat, based on the free windocks community edition .
comparing windocks to microsoft's windows server 2016 implementation
the windocks setup is an automated 15-minute install on any edition of windows 8, windows 10, windows server 2012, and windows server 2016. windocks uses standard docker commands, which can be run locally or from a remote client. in this article we’ll use a local client on a windows 8 home edition laptop as our container server!
windows containers behave like linux containers, with speed, portability of containers and images, and great economy. a survey of windocks customers shows an average reduction in vms used of 5x, and for dev and test usage the reduction in vms averages close to 10x.
how does windocks compare to microsoft’s container support on windows server 2016?
- microsoft’s supports windows server 2016 and windows 10 enterprise editions only, while windocks supports all editions of windows 8 and windows server 2012 onward.
- microsoft has two sql server express dockerfiles on dockerhub, but provides no build time support for attaching sql server databases! windocks supports all editions of sql server 2008 onward, with dockerfile support for adding or mounting databases and running sql server scripts. sql server containers built using windocks are complete and ready for use.
windocks support of java and tomcat
windocks ships with a \samples folder that includes dockerfiles for ngnix, node.js, tomcat, jetty, and of course .net and sql server. the tomcat test folder is shown below, along with a sample dockerfile. the dockerfile uses the new “windows” image, along with tomcat version 7.0.72, and a powershell script that sets the tomcat server port to the container port.
if you have a war file, it could be added with an additional copy command, or it could be pulled from the appropriate repo. the command to build the container is >docker build <path>. the “testjavatomcat” folder is included in the windocks samples directory. each container includes a unique containerid, and an assigned port (underlined below). we then start the container using the >docker start <id>.
opening a browser to localhost:<port> (we’re working on the windocks host), we can see our container is built and running. windows task manager also confirms that we have java.exe running in a container.
create a tomcat image
now that we’ve created a running container, we can commit this as an image, with >docker commit <containerid> <imagename>. once saved we can create as many identical, isolated containers as needed. saved and tested images become artifacts in a continuous integration process. we’ll write again soon about the new windocks jenkins build plugin.
each tomcat container is built with a dockerfile that includes a script to ensure the tomcat port is matched to the container port. again, the container has a containerid, and port, and we can start it as shown.
the result is easily confirmed with a refreshed browser pointing to the new container port.
do more, faster, and spend less!
if you haven’t explored the use of containers, now is the time! windocks customers use a single vm to support a team of developers or testers, saving time and money. one windocks customer uses a bare metal host with 8 cores and 96 gb of ram, to support twenty sql server containers for dev and test. each container includes over twenty large databases! prior to using containers, each vm took over an hour to provision. using windocks the time is down to a couple of minutes. the result is a 20x reduction in vms, a 5:1 reduction in cpu cores, and a dramatic financial savings in ms license costs.
Opinions expressed by DZone contributors are their own.