Running Apache Tomcat in Windows Containers
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
Learn how to migrate and modernize stateless applications and run them in a Kubernetes cluster.
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.