[null, {"document_url": "https://blog.eisele.net/2015/05/java-ee-deployment-secenarios-for-docker.html", "unformatted_src": "//2.bp.blogspot.com/-riwA4j37guc/VWhLY2mDOUI/AAAAAAAA5x8/C_HkNy1lG2w/s200/container.jpg", "src": "http://2.bp.blogspot.com/-riwA4j37guc/VWhLY2mDOUI/AAAAAAAA5x8/C_HkNy1lG2w/s200/container.jpg", "formatted_filename": "container", "rendered_width": 200, "rendered_height": 200}, null, {"document_url": "https://blog.eisele.net/2015/05/java-ee-deployment-secenarios-for-docker.html", "unformatted_src": "//1.bp.blogspot.com/-l0gtlAYa5KE/VWhDJ0dYkqI/AAAAAAAA5xs/nuBTxlKUywI/s320/plain-wildfly0.png", "src": "http://1.bp.blogspot.com/-l0gtlAYa5KE/VWhDJ0dYkqI/AAAAAAAA5xs/nuBTxlKUywI/s320/plain-wildfly0.png", "formatted_filename": "plain wildfly", "rendered_width": 320, "rendered_height": 153}, null, {"document_url": "https://blog.eisele.net/2015/05/java-ee-deployment-secenarios-for-docker.html", "unformatted_src": "//lh4.googleusercontent.com/-NH3YxnBXzf0/AAAAAAAAAAI/AAAAAAAAu2o/5_bSBtIpFcY/s80-c/photo.jpg", "src": "http://lh4.googleusercontent.com/-NH3YxnBXzf0/AAAAAAAAAAI/AAAAAAAAu2o/5_bSBtIpFcY/s80-c/photo.jpg", "formatted_filename": "photo", "alt_text": "My Photo", "rendered_width": 80, "rendered_height": 80}, null, null, {"document_url": "https://blog.eisele.net/2015/05/java-ee-deployment-secenarios-for-docker.html", "unformatted_src": "//1.bp.blogspot.com/-0LZ6sawE_BA/VvP3Fm3x5SI/AAAAAAABEOg/pen4RNBtiXA9-iuY5AmvL12wr0zECbSqw/s1600-r/hero_jonas_200x230_oreillymicroservices5.png", "src": "http://1.bp.blogspot.com/-0LZ6sawE_BA/VvP3Fm3x5SI/AAAAAAABEOg/pen4RNBtiXA9-iuY5AmvL12wr0zECbSqw/s1600-r/hero_jonas_200x230_oreillymicroservices5.png", "formatted_filename": "hero jonas oreillymicroservices", "alt_text": "Reactive Microservices Architecture", "rendered_width": 200, "rendered_height": 270}, null, null]

Java EE Deployment Scenarios for Docker Containers

13:20 Friday, May 29, 2015 Posted by Markus Eisele
Docker, javaee, wildfly I've been posting some content around Docker since a while and I like to play around with containers in general. You can find some more information about how to run Docker-Machine on Windows and also showed you how to use the Docker 1.6 client. One of the first blog posts was a compilation of all kinds of resources around Java EE, Docker and Maven for Java EE developers. Working more detailed and often with containers brings up the question about how Java EE applications should be distributed and how developers should use containers. This tries to clarify a little and give you a good overview about the different options.

Base Image Image vs. Custom Image and Some Basics
Most likely, your application server of choice is available on the public registry, known as docker hub. This is true for WildFly. The first decision you have to make is, if you want to use one of the base images or if you are going to bake your own image. Running with the base is pretty much:
and your instance is up and running in a second, after the base image was downloaded. But what does that mean? And how does it work? At the heart of every container is Linux. A teensy one. In a normal Linux, the kernel first mounts the root File System as read-only, checks its integrity, and then switches the whole rootfs volume to read-write mode. The teensy Linux in a Docker container does that differently. Instead of changing the file system to read-write mode, it takes advantage of a union mount to add a read-write file system over the read-only file system. In fact there may be multiple read-only file systems stacked on top of each other. If you look at the jboss/wildfly image, this is what you get on first sight: You see four different levels in this picture. Let's not call them layer, because they aren't yet. This is the hierarchy of images which are the base for our jboss/wildfly image. Each of those images is composed out of a Dockerfile. This is an empty text file with a bunch of instructions in it. You can think of it as a sort of pom-file which needs do be processed through a tool called "Builder". It can contain a variety of commands and options to add users, volumes, add software, downloads and many many more.  If you look at the jboss/wildfly Dockerfile you see the commands that compose the image:
The first line defines the base from which the image is derived. Looking at the jboss/base-jdk:7 Dockerfile reveals the root which is jboss/base.
Now imagine, that every single one of those lines does something to the filesystem. Most obvious example is a download. It adds something to it. But instead of writing it to an already mounted partition, it get's stacked up as a new layer. Looking at all the layers of jboss/wildfly this sums up to 19 unique layers with a total size of 951mb.

Using the base image, you can expect to have a default configuration at hand. And this is a great place to start. We at JBoss try to make our projects (and products too!) usable out-of-box for as many use cases as we can, but there is no way that one configuration could satisfy everyone’s needs. For example, we ship 4 flavors of the standalone.xml configuration file with WildFly since there are so many different deployment scenarios. But this is still not enough. We need to be able to tweak it at any point. The jboss/wildfly image is not an exception here.
Creating a custom image with

is your first step into the word of a customized image. If you want to know, how to do that, there is an amazing blog post which covers almost all the details.

Java EE Applications - On Docker
One of the main principles behind Docker is "Recreate — Do Not Modify ". With a container being a read-only, immutable piece of infrastructure with very limited capabilities to be changed at runtime, you might be interested in the different options you have to deploy your application.

Dockerize It
This is mostly referred to as "custom image" beside the needed configuration changes, you also add the binary of your application as a new layer your image.
Done. Build, Push and run your custom image. If one instance dies, don't worry and fire up a new one.

- No re-deployments. Every
- No changes
- New version, new image version
- Not the typical operations model for now.
- Might need additional tooling (plugins for Maven/Jenkins)

- The Docker Way
- Easy to integrate into your project build.
- Easy to roll-out and configure

Containers as Infrastructure
There's no real term for it. It basically means that you don't care how your infrastructure is run. This might be the called old-fashioned operations model. You will need to have some kind of access to the infrastructure. Either a shared filesystem with the host to deploy applications via the deployment scanner or the management ports need to be open in order to use the CLI or other tooling to deploy your applications into the container.

- More complex layering to keep state in containers
- Not the Docker Way
- Not fancy.
- Centralized ops and administration

- Hardly any change to what you're used to as a developer in enterprises today
- Doesn't need to be integrated into your build at all. It's just an instance running somewhere

- No additional tooling.

This is hard. I'd suggest, that you look into what fits best for your situation. Most of the enterprise companies might tend to stick with the Containers as Infrastructure solution. This has a lot of drawbacks for now looking at it from a developers perspective. A decent intermediate solution might be OpenShift v3 which will optimize operations for containers and bring a lot of usability and comfort to the Java EE PaaS world.
If you are free to make a choice, you can totally go with the "Dockerize" way. Keep in mind, that this is a vendor-lock-in as of today and some more promising and open solutions on the horizon already.
