Over a million developers have joined DZone.

Running Apache Tomcat in Windows Containers

If you're using Windows containers, check out WinDocks' latest support for Java and Tomcat.

· Cloud Zone

Download the Essential Cloud Buyer’s Guide to learn important factors to consider before selecting a provider as well as buying criteria to help you make the best decision for your infrastructure needs, brought to you in partnership with Internap.

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. 

Image title

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>.

Image title

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.

Image title

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. 

Image title

The result is easily confirmed with a refreshed browser pointing to the new container port.

Image title

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. 

The Cloud Zone is brought to you in partnership with Internap. Read Bare-Metal Cloud 101 to learn about bare-metal cloud and how it has emerged as a way to complement virtualized services.

Topics:
apache tomcat 7 ,windows server 2012 ,cloud ,docker

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}