Try using another Servlet container Jetty with Docker

Eclipse Jetty is a Java Servlet execution environment (servant container, partial implementation of Java EE) and a web server. Apache Tomcat is a well-known implementation of the Servlet container, but Jetty is older [^ 1] and lighter [^ 2]. Commercial support is provided by the active contributor Webtide and embedded in Apache Hadoop. / Jetty) or used by Google App Engine.

[^ 1]: Jetty was first released in 1995 and Tomcat was first released in 1999.

Jetty has a smaller memory footprint than Tomcat, which helps save resources when running Java Servlets in a containerized virtualized environment. This article introduces the procedure for using Jetty on Docker.

Use Jetty with Docker

Docker Official Image is provided [^ 3]. You can choose an image from a combination of OpenJDK LTS (Red Hat build) and JRE, Debian and Debian slim for each version of Jetty.

version Developer Java Java EE Servlet JSP Support period Status Remarks
11 Eclipse 11~ 8 4.0.2 2.3 2020~ alpha Changed to JakartaEE Namespace
10 Eclipse 11~ 8 4.0.2 2.3 2019~ beta
9.4 Eclipse 1.8~ 7 3.1 2.3 2016~ Stable version
9.3 Eclipse 1.8~ 7 3.1 2.3 2015~ not recommended HTTP/2, support FastCGI
9.2 Eclipse 1.7~ 7 3.1 2.3 2014~2018 EOL Started distributing Docker images
9.1 Eclipse 1.7~ 7 3.1 2.3 2013~2014 EOL
9 Eclipse 1.7~ 7 3.1-beta 2.3 2013~2013 EOL
8 Eclipse/Codehaus 1.6~ 6 3 2.2 2009~2014 EOL
7 Eclipse/Codehaus 1.5~ 5 2.5 2.1 2008~2014 EOL Supports WebSocket and SPDY v3
6 Codehaus 1.4~1.5 5 2.5 2 2006~2010 EOL
5 Sourceforge 1.2~1.5 1.4 2.4 2 2003~2009 Antique (antique)
4 Sourceforge 1.2、J2ME 1.3 2.3 1.2 2001~2006 Ancient
3 Sourceforge 1.2 1.2 2.2 1.1 1999~2002 Fossilized HTTP/1.Support 1
2 Mortbay 1.1 - 2.1 1 1998~2000 Legendary
1 Mortbay 1 - - - 1995~1998 Mythical

Here we select Jetty9 on OpenJDK11 on Debian10:

[^ 3]: By the way, Google Cloud Platform Jetty Docker Image is also published under Apache-2.0 license.

docker pull jetty:9.4.31-jdk11

Deploying the Servlet is easy, just put the WAR file in / var / lib / jetty / webapps, or the uncompressed Servlet directory:

FROM jetty:9.4.31-jdk11
ADD sample.war /var/lib/jetty/webapps

You can also specify any location in context.xml:

FROM jetty:9.4.31-jdk11
ADD sampleApp.xml /var/lib/jetty/webapps
ADD sample /usr/local/sample

sampleApp.xml


<Configure class="org.eclipse.jetty.webapp.WebAppContext">
    <Set name="contextPath">/sample</Set>
    <Set name="war">/usr/local/sample</Set>
</Configure>

Environmental setting

You can refer to the current preferences by specifying the --list-config option:

$ docker run --rm jetty:9.4.31-jdk11 --list-config

Java Environment:
-----------------
 java.home = /usr/local/openjdk-11 (null)
 java.vm.vendor = Oracle Corporation (null)
 java.vm.version = 11.0.8+10 (null)
 java.vm.name = OpenJDK 64-Bit Server VM (null)
 java.vm.info = mixed mode (null)
 java.runtime.name = OpenJDK Runtime Environment (null)
 java.runtime.version = 11.0.8+10 (null)
 java.io.tmpdir = /tmp/jetty (null)
 user.dir = /var/lib/jetty (null)
 user.language = en (null)
 user.country = null (null)

Jetty Environment:
-----------------
 jetty.version = 9.4.31.v20200723
 jetty.tag.version = master
 jetty.home = /usr/local/jetty
 jetty.base = /var/lib/jetty

Config Search Order:
--------------------
 <command-line>
 ${jetty.base} -> /var/lib/jetty
 ${jetty.home} -> /usr/local/jetty


JVM Arguments:
--------------
 (no jvm args specified)

System Properties:
------------------
 (no system properties specified)

Properties:
-----------
 java.version = 11.0.8
 java.version.major = 11
 java.version.micro = 8
 java.version.minor = 0
 java.version.platform = 11
 jetty.base = /var/lib/jetty
 jetty.base.uri = file:///var/lib/jetty
 jetty.home = /usr/local/jetty
 jetty.home.uri = file:///usr/local/jetty

Jetty Server Classpath:
-----------------------
Version Information on 37 entries in the classpath.
Note: order presented here is how they would appear on the classpath.
      changes to the --module=name command line options will be reflected here.
 0:      1.4.1.v201005082020 | ${jetty.home}/lib/mail/javax.mail.glassfish-1.4.1.v201005082020.jar
 1:                    (dir) | ${jetty.base}/resources
 2:                    3.1.0 | ${jetty.home}/lib/servlet-api-3.1.jar
 3:                 3.1.0.M0 | ${jetty.home}/lib/jetty-schemas-3.1.jar
 4:         9.4.31.v20200723 | ${jetty.home}/lib/jetty-http-9.4.31.v20200723.jar
 5:         9.4.31.v20200723 | ${jetty.home}/lib/jetty-server-9.4.31.v20200723.jar
 6:         9.4.31.v20200723 | ${jetty.home}/lib/jetty-xml-9.4.31.v20200723.jar
 7:         9.4.31.v20200723 | ${jetty.home}/lib/jetty-util-9.4.31.v20200723.jar
 8:         9.4.31.v20200723 | ${jetty.home}/lib/jetty-io-9.4.31.v20200723.jar
 9:         9.4.31.v20200723 | ${jetty.home}/lib/jetty-jndi-9.4.31.v20200723.jar
10:         9.4.31.v20200723 | ${jetty.home}/lib/jetty-security-9.4.31.v20200723.jar
11:                      1.3 | ${jetty.home}/lib/transactions/javax.transaction-api-1.3.jar
12:         9.4.31.v20200723 | ${jetty.home}/lib/jetty-servlet-9.4.31.v20200723.jar
13:         9.4.31.v20200723 | ${jetty.home}/lib/jetty-webapp-9.4.31.v20200723.jar
14:         9.4.31.v20200723 | ${jetty.home}/lib/jetty-plus-9.4.31.v20200723.jar
15:         9.4.31.v20200723 | ${jetty.home}/lib/jetty-annotations-9.4.31.v20200723.jar
16:                    7.3.1 | ${jetty.home}/lib/annotations/asm-7.3.1.jar
17:                    7.3.1 | ${jetty.home}/lib/annotations/asm-analysis-7.3.1.jar
18:                    7.3.1 | ${jetty.home}/lib/annotations/asm-commons-7.3.1.jar
19:                    7.3.1 | ${jetty.home}/lib/annotations/asm-tree-7.3.1.jar
20:                      1.3 | ${jetty.home}/lib/annotations/javax.annotation-api-1.3.jar
21:    3.19.0.v20190903-0936 | ${jetty.home}/lib/apache-jsp/org.eclipse.jdt.ecj-3.19.0.jar
22:         9.4.31.v20200723 | ${jetty.home}/lib/apache-jsp/org.eclipse.jetty.apache-jsp-9.4.31.v20200723.jar
23:                   8.5.54 | ${jetty.home}/lib/apache-jsp/org.mortbay.jasper.apache-el-8.5.54.jar
24:                   8.5.54 | ${jetty.home}/lib/apache-jsp/org.mortbay.jasper.apache-jsp-8.5.54.jar
25:                    1.2.5 | ${jetty.home}/lib/apache-jstl/org.apache.taglibs.taglibs-standard-impl-1.2.5.jar
26:                    1.2.5 | ${jetty.home}/lib/apache-jstl/org.apache.taglibs.taglibs-standard-spec-1.2.5.jar
27:         9.4.31.v20200723 | ${jetty.home}/lib/jetty-client-9.4.31.v20200723.jar
28:         9.4.31.v20200723 | ${jetty.home}/lib/jetty-deploy-9.4.31.v20200723.jar
29:                      1.0 | ${jetty.home}/lib/websocket/javax.websocket-api-1.0.jar
30:         9.4.31.v20200723 | ${jetty.home}/lib/websocket/javax-websocket-client-impl-9.4.31.v20200723.jar
31:         9.4.31.v20200723 | ${jetty.home}/lib/websocket/javax-websocket-server-impl-9.4.31.v20200723.jar
32:         9.4.31.v20200723 | ${jetty.home}/lib/websocket/websocket-api-9.4.31.v20200723.jar
33:         9.4.31.v20200723 | ${jetty.home}/lib/websocket/websocket-client-9.4.31.v20200723.jar
34:         9.4.31.v20200723 | ${jetty.home}/lib/websocket/websocket-common-9.4.31.v20200723.jar
35:         9.4.31.v20200723 | ${jetty.home}/lib/websocket/websocket-server-9.4.31.v20200723.jar
36:         9.4.31.v20200723 | ${jetty.home}/lib/websocket/websocket-servlet-9.4.31.v20200723.jar

Jetty Active XMLs:
------------------
 ${jetty.home}/etc/jetty-bytebufferpool.xml
 ${jetty.home}/etc/jetty-threadpool.xml
 ${jetty.home}/etc/jetty.xml
 ${jetty.home}/etc/jetty-webapp.xml
 ${jetty.home}/etc/jetty-plus.xml
 ${jetty.home}/etc/jetty-annotations.xml
 ${jetty.home}/etc/jetty-deploy.xml
 ${jetty.home}/etc/jetty-http.xml

Please refer to Official Documentation for the items that can be set.

The JVM options can be specified with the environment variable JAVA_OPTIONS.

Reference link

Recommended Posts

Try using another Servlet container Jetty with Docker
Try using Kong + Konga with Docker Compose.
Try WildFly with Docker
Try using DI container with Laravel and Spring Boot
People using docker Try using docker-compose
Using PlantUml with Honkit [Docker]
Try Hello World using plain Java on a Docker container
Try using Redmine on Mac docker
Try running cloudera manager with docker
Try implementing recaptcha with Jetty embedded.
Try using Redis with Java (jar)
[Linux] Start Apache container with Docker
Use cuda11.0 with pytorch using Docker
Build WebRTC Janus with Docker container
Check the operation using jetty with Maven.
I tried using Scalar DL with Docker
Try running Slack's (Classic) Bot with docker
Try using Spring Boot with VS Code
Proxy server with squid using docker image
Quick build maven project using maven docker container
GPU recognition with docker using WSL2 (August 2020)
Try using the Wii remote with Java
Try running MPLS-VPN with FR Routing on Docker
Extract key phrases using Text Analytics Docker container
Keep docker container running with no resident process running
Build a Kotlin app using OpenJDK's Docker container
Try running OSPF with FR Routing on Docker
Try using GPS receiver kit with RaspberryPi3 (Ruby)
Setting to exit from Docker container with VScode
Send emails using Docker container on Raspberry Pi 3
Try RESTful web services with Nablarch's container archetype
Update container image with KUSANAGI Runs on Docker
Try building Express + PostgreSQL + Sequelize with Docker [Part 1]
Docker Container Operations with Docker-Client API for Java
Try using S3Proxy with Microsoft Azure Blob Storage
Try using libGDX
Try using Maven
Try using powermock-mockito2-2.0.2
Try using GraalVM
Try using jmockit 1.48
Try using sql-migrate
[Docker] How to update using a container on Heroku and how to deal with Migrate Error
Try using SwiftLint
Try using Log4j 2.0
Small Docker container
Until you try running Apache Kafka with docker image
Try using OpenID Connect with Keycloak (Spring Boot application)
Access and debug Circle CI Docker container with ssh
Run the Android emulator on Docker using Android Emulator Container Scripts
Feel free to try Elasticsearch cluster with WSL2 + Docker
Try connecting to AzureCosmosDB Emulator for Docker with Java
[Docker] Build an Apache container on EC2 using dockerfile
Run Mosquitto with Docker and try WebSocket communication with MQTT
Try to build a Java development environment using Docker
Command to try using Docker for the time being
Try to work with Keycloak using Spring Security SAML (Spring 5)