Ready-made Java-based Containers, Part One
Despite not being seen as very "trendy", Java is a hugely popular and important language that dominates the mobile market, open source, and of course, the enterprise. Did you know, for instance, that 63% of the projects at The Apache Software Foundation are written in Java?
Fortunately, Java developers aren’t left out in the cold by advances in container technology. And this post highlights four popular Java-based Docker images, their configuration, and how they can help your team work more efficiently.
Stash is a code management and collaboration tool for Git. Stash allows deployment nodes to be clustered, reducing downtime across active servers without taking a performance hit for each added node. Stash also integrates with JIRA (made by the same company) for traceability, while offering collaboration tools for teams with features such as alerting when code changes are made while a pull request is open.
If you’re looking to move a Git remote from one Stash instance to another, be aware that while you can clone your repo, your pull requests won’t be copied over. You also cannot move between Stash instances. Though, the Stash development team would like to add these features in the future.
If generating a JIRA database schema, be aware that JIRA 6.1 EAP 3 contains breaks which could cause your addons to stop working.
Stash lets teams restrict write access to important branches of code, ensuring that code isn’t rewritten by new team members. Stash allows for developers to push code to their own server-side repo, which then can be approved by a project manager and merged with the main project repository.
When starting a new project in Stash, project managers should begin with a bare repository:
All other team members should SSH into this repository and clone it to another location on the server. Stash calls this the Forking Workflow, which may seem very unusual to those from an SVN background.
Tomcat is an OSS web server and servlet container implementing the Java Servlet and JavaServer Pages (JSP) specificactions from Oracle. This provides a standard HTTP environment to run code in. In its simplest configuration, Tomcat runs in a single OS process. Installing Tomcat via a container ensures that developers working on older machines don’t have to use a full VM environment, thus freeing up resources.
Running Tomcat in Docker containers can result in poor performance for users running Linux VMs where the container is slow to boot or incredibly sluggish.
Using an Entropy Gathering Daemon (EDG) is a workaround for this issue for users that are running Linux based hosts. If you’re is working inside Boot2Docker, this issue is exacerbated by the fact that Boot2Docker does not have an EGD currently available in its Tiny Core Linux extensions. Mounting
/dev/urandom (from the host) as
/dev/random (inside the container) has also been offered as a temporary workaround.
If your VM is also experiencing low entropy while running Tomcat in Docker, VirtualBox has some solutions for increasing VM entropy.
Apache Hadoop is an OSS framework for the distribution of large data sets across a large number of computers. Hadoop is designed to scale from a single machine up to tens of thousands. Hadoop doesn’t rely on hardware to address fault-tolerance, and is able to handle failures at the application level. The Hadoop framework consists of four modules, including: Hadoop Common, Hadoop Distributed File System (HDFS), Hadoop YARN, and Hadoop MapReduce. There are a number of other Hadoop related projects available, including: ZooKeeper and Spark.
Running Hadoop can prove frustrating in Docker if you’re attempting to set up multi-node clusters. Networking between containers can be done by using Weave, or through SequenceIQ’s new project, Cloudbreak. Cloudbreak can create Hadoop clusters on many different cloud providers (such as AWS) with ease.
Users have also experienced difficulties running pyspark, a Spark programming model used in Python, in a Hadoop container. Attempting to save dataframes in pyspark as a non-root user fails. Resetting the
$SPARK_USER to root also has no effect on this, as spark child nodes are always executed as root. If your project does not require a permissions system, a workaround to this issue has been posted to the user mailing list.
Apache Maven is a software project management tool based around the concept of a Project Object Model (POM). This allows Maven to manage a project’s build, documentation, or reporting from a central information source. Maven also offers useful tools when developing. These include the possibility to provide a project’s mailing lists, change logs from source control, dependency lists, or unit test reports.
When running Maven’s Docker plugin, there is a current bug where a blank
CMD will be outputted if a user does not specify one. This can be frustrating for users that want their containers to inherit parent information. Using the official Docker image should alleviate these issues.
If your server is running Jenkins, setting options to create a release or a snapshot can quickly become a hassle when dealing with Docker arguments for the
mvn command. The Jenkins Maven release plugin automates the process of configuring
pom.xml and deploying the snapshot.
Glassfish is an OSS application server, supporting Enterprise JavaBeans, JPA, JavaServer Faces, JMI, JavaServer pages, and more. Glassfish enables developers to create applications that scale, are portable, and integrate with legacy technology. Additional components can be installed alongside Glassfish to access other services.
Glassfish offers two additional images on the Docker hub to developers wanting to test new features: Nightly and Ozark. Ozark contains MVC 1.0 running Glassfight 4.1, enabling it to run Java EE 8.
Glassfish is currently experiencing a bug involving domain corruption. Users may choose to delete the
glassfish/domain/domains generated folder as a result. Upon attempting to do so, the files will appear to be locked, unable to be deleted even after completing a fresh install of Glassfish 4.1 in the container. To work around this issue, there have been a number of solutions posted. The most common is to move the structure unable to be deleted up one level, then deleting it, as was offered as a solution to this issue on GitHub.
In this post we looked at these five images:
- Stash allows for code management, peer review, and a streamlined workflow for development teams to manage their Git repositories.
- Tomcat provides a lightweight HTTP environment to compile code in, freeing system resources by eliminating the need for multiple VM instances.
- Hadoop offers a framework to distribute large amounts of data across multiple computers with ease.
- Maven manages project builds by automating the process across all instances of an application.
- Glassfish enables developers to work in EE Java and integrate with legacy applications.
These are great examples of Java applications and devops tools available via the Docker hub that you that you can use in conjunction with Docker to improve your workflow, project pipeline, and project scalability.