Jersey Grizzly HTTP Server shutdown inside container docker - java

I am trying to execute a Grizzly HTTP Server inside a container.
My problem is that when I am running the container (using docker-compose) the container shuts down after a few seconds.
Here is my server Dockerfile:
FROM alpine:3.5
MAINTAINER Maybe One <maybe#maybe.com>
# Java Version and other ENV
ENV JAVA_VERSION_MAJOR=8 \
JAVA_VERSION_MINOR=102 \
JAVA_VERSION_BUILD=14 \
JAVA_PACKAGE=jdk \
JAVA_JCE=standard \
JAVA_HOME=/opt/jdk \
PATH=${PATH}:/opt/jdk/bin \
GLIBC_VERSION=2.23-r3 \
LANG=C.UTF-8
RUN apk upgrade --update && \
apk add --update libstdc++ curl ca-certificates bash && \
for pkg in glibc-${GLIBC_VERSION} glibc-bin-${GLIBC_VERSION} glibc-i18n-${GLIBC_VERSION}; do curl -sSL https://github.com/andyshinn/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/${pkg}.apk -o /tmp/${pkg}.apk; done && \
apk add --allow-untrusted /tmp/*.apk && \
rm -v /tmp/*.apk && \
( /usr/glibc-compat/bin/localedef --force --inputfile POSIX --charmap UTF-8 C.UTF-8 || true ) && \
echo "export LANG=C.UTF-8" > /etc/profile.d/locale.sh && \
/usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib && \
mkdir /opt && \
curl -jksSLH "Cookie: oraclelicense=accept-securebackup-cookie" -o /tmp/java.tar.gz \
http://download.oracle.com/otn-pub/java/jdk/${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-b${JAVA_VERSION_BUILD}/${JAVA_PACKAGE}-${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-linux-x64.tar.gz && \
gunzip /tmp/java.tar.gz && \
tar -C /opt -xf /tmp/java.tar && \
ln -s /opt/jdk1.${JAVA_VERSION_MAJOR}.0_${JAVA_VERSION_MINOR} /opt/jdk && \
if [ "${JAVA_JCE}" == "unlimited" ]; then echo "Installing Unlimited JCE policy" >&2 && \
curl -jksSLH "Cookie: oraclelicense=accept-securebackup-cookie" -o /tmp/jce_policy-${JAVA_VERSION_MAJOR}.zip \
http://download.oracle.com/otn-pub/java/jce/${JAVA_VERSION_MAJOR}/jce_policy-${JAVA_VERSION_MAJOR}.zip && \
cd /tmp && unzip /tmp/jce_policy-${JAVA_VERSION_MAJOR}.zip && \
cp -v /tmp/UnlimitedJCEPolicyJDK8/*.jar /opt/jdk/jre/lib/security; \
fi && \
sed -i s/#networkaddress.cache.ttl=-1/networkaddress.cache.ttl=30/ $JAVA_HOME/jre/lib/security/java.security && \
apk del curl glibc-i18n && \
rm -rf /opt/jdk/*src.zip \
/opt/jdk/lib/missioncontrol \
/opt/jdk/lib/visualvm \
/opt/jdk/lib/*javafx* \
/opt/jdk/jre/plugin \
/opt/jdk/jre/bin/javaws \
/opt/jdk/jre/bin/jjs \
/opt/jdk/jre/bin/orbd \
/opt/jdk/jre/bin/pack200 \
/opt/jdk/jre/bin/policytool \
/opt/jdk/jre/bin/rmid \
/opt/jdk/jre/bin/rmiregistry \
/opt/jdk/jre/bin/servertool \
/opt/jdk/jre/bin/tnameserv \
/opt/jdk/jre/bin/unpack200 \
/opt/jdk/jre/lib/javaws.jar \
/opt/jdk/jre/lib/deploy* \
/opt/jdk/jre/lib/desktop \
/opt/jdk/jre/lib/*javafx* \
/opt/jdk/jre/lib/*jfx* \
/opt/jdk/jre/lib/amd64/libdecora_sse.so \
/opt/jdk/jre/lib/amd64/libprism_*.so \
/opt/jdk/jre/lib/amd64/libfxplugins.so \
/opt/jdk/jre/lib/amd64/libglass.so \
/opt/jdk/jre/lib/amd64/libgstreamer-lite.so \
/opt/jdk/jre/lib/amd64/libjavafx*.so \
/opt/jdk/jre/lib/amd64/libjfx*.so \
/opt/jdk/jre/lib/ext/jfxrt.jar \
/opt/jdk/jre/lib/ext/nashorn.jar \
/opt/jdk/jre/lib/oblique-fonts \
/opt/jdk/jre/lib/plugin.jar \
/tmp/* /var/cache/apk/*
# Maven
ENV MAVEN_VERSION 3.3.9
ENV MAVEN_HOME /usr/lib/mvn
ENV PATH $MAVEN_HOME/bin:$PATH
RUN wget http://ftp.fau.de/apache/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz && \
tar -zxvf apache-maven-$MAVEN_VERSION-bin.tar.gz && \
rm apache-maven-$MAVEN_VERSION-bin.tar.gz && \
mv apache-maven-$MAVEN_VERSION /usr/lib/mvn
# Workspace
ENV WORKSPACE /home/app/
RUN mkdir -p $WORKSPACE
WORKDIR $WORKSPACE
COPY . $WORKSPACE # Copy Server Project
RUN mvn clean install -DskipTests
ENTRYPOINT mvn exec:java
docker-compose.yml
version: '2.1'
services:
server:
build: ./server/
ports:
- "8080:8080"
server docker logs:
... maven...
[INFO] --- exec-maven-plugin:1.2.1:java (default-cli) # restful.littleapp ---
Jan 30, 2017 2:10:18 PM org.glassfish.grizzly.http.server.NetworkListener start
INFO: Started listener bound to [0.0.0.0:8080]
Jan 30, 2017 2:10:18 PM org.glassfish.grizzly.http.server.HttpServer start
INFO: [HttpServer] Started.
Jersey app started with WADL available at http://0.0.0.0:8080/littleapp/application.wadl
Hit enter to stop it...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.507 s
[INFO] Finished at: 2017-01-30T14:10:18+00:00
Jan 30, 2017 2:10:18 PM org.glassfish.grizzly.http.server.NetworkListener shutdownNow
INFO: Stopped listener bound to [0.0.0.0:8080]
[INFO] Final Memory: 37M/90M
[INFO] ------------------------------------------------------------------------
Normally, the server has to listen...

The problem is probably that your main class is waiting for input before stopping the grizzly server. Since the docker container is not run in interactive mode it will never get input on command line and the System.in is terminated. The mvn exec process stops.
You should find a way to keep the grizzly server running without waiting for input.
Something like
server.start();
Thread.currentThread().join(); // instead of System.in.read();
edit: seems there is a solution like this already described on s.o. grizzly-http-server-should-keep-running which also incorporates a graceful shutdown by mean of a shutdownhook.

Related

Copying Java from one build to another using docker-compose

I need some help to put two Docker images together.
First, I have this Dockerfile/docker-compose files, for a Docker container with ROS. Alone, it works fine.
Dockerfile:
ARG FROM_IMAGE=ros:foxy
ARG OVERLAY_WS=/opt/ros/overlay_ws
# multi-stage for caching
FROM $FROM_IMAGE AS cacher
# clone overlay source
ARG OVERLAY_WS
WORKDIR $OVERLAY_WS/src
RUN echo "\
repositories: \n\
ros2/codigo_gustavo: \n\
type: git \n\
url: https://github.com/GustavoLLima/codigo_gustavo.git \n\
version: master \n\
" > ../overlay.repos
RUN vcs import ./ < ../overlay.repos
# copy manifests for caching
WORKDIR /opt
RUN mkdir -p /tmp/opt && \
find ./ -name "package.xml" | \
xargs cp --parents -t /tmp/opt && \
find ./ -name "COLCON_IGNORE" | \
xargs cp --parents -t /tmp/opt || true
# multi-stage for building
FROM $FROM_IMAGE AS builder
# install overlay dependencies
ARG OVERLAY_WS
WORKDIR $OVERLAY_WS
COPY --from=cacher /tmp/$OVERLAY_WS/src ./src
RUN . /opt/ros/$ROS_DISTRO/setup.sh && \
apt-get update && rosdep install -y \
--from-paths \
src \
--rosdistro \
foxy \
&& rm -rf /var/lib/apt/lists/*
# build overlay source
COPY --from=cacher $OVERLAY_WS/src ./src
ARG OVERLAY_MIXINS="release"
RUN . /opt/ros/$ROS_DISTRO/setup.sh && \
colcon build \
--packages-select \
codigo_gustavo \
--mixin $OVERLAY_MIXINS
# source entrypoint setup
ENV OVERLAY_WS $OVERLAY_WS
RUN sed --in-place --expression \
'$isource "$OVERLAY_WS/install/setup.bash"' \
/ros_entrypoint.sh
Docker-compose.yml:
version: '3'
services:
talker:
build: ./
command: ros2 run codigo_gustavo talker
listener:
build: ./
environment:
- "PYTHONUNBUFFERED=1"
command: ros2 run codigo_gustavo listener
deploy:
mode: replicated
replicas: 2
Then, I have another Dockerfile/Docker-Compose files for a Docker container running NetLogo. Again, alone it works fine.
Dockerfile:
FROM openjdk:8-jdk
LABEL maintainer="Allen Lee <allen.lee#asu.edu>"
ARG NETLOGO_HOME=/opt/netlogo
ARG NETLOGO_VERSION=6.0.4
ENV LC_ALL=C.UTF-8 \
LANG=C.UTF-8 \
NETLOGO_TARBALL=NetLogo-$NETLOGO_VERSION-64.tgz
ENV NETLOGO_URL=https://ccl.northwestern.edu/netlogo/$NETLOGO_VERSION/$NETLOGO_TARBALL
WORKDIR /opt
RUN wget $NETLOGO_URL && tar xzf $NETLOGO_TARBALL && ln -sf "NetLogo $NETLOGO_VERSION" netlogo \
&& rm -f $NETLOGO_TARBALL
Docker-compose.yml:
version: '3'
services:
modelo1:
build: ./
command: tail -f /dev/null
volumes:
- ./teste:/teste
volumes:
teste:
Now the problem: I'm trying to merge these two, to use just one Dockerfile/Docker-Compose files, making it easier to run. The problem is that I managed to make the two containers, but when I try to run the NetLogo (via netlogo headless), the container can't find Java (dependency of NetLogo). I checked in the directory, and it seems like Java isn't installed. The workspace comes with both folders, NetLogo and ROS.
Dockerfile:
#--------------Netlogo Instalation--------------
ARG FROM_IMAGE=ros:foxy
ARG OVERLAY_WS=/opt/ros/overlay_ws
#FROM openjdk:8-jdk AS netlogo_cache
FROM openjdk:8-jdk
LABEL maintainer="Allen Lee <allen.lee#asu.edu>"
ARG NETLOGO_HOME=/opt/netlogo
ARG NETLOGO_VERSION=6.0.4
ENV LC_ALL=C.UTF-8 \
LANG=C.UTF-8 \
NETLOGO_TARBALL=NetLogo-$NETLOGO_VERSION-64.tgz
ENV NETLOGO_URL=https://ccl.northwestern.edu/netlogo/$NETLOGO_VERSION/$NETLOGO_TARBALL
WORKDIR /opt
RUN wget $NETLOGO_URL && tar xzf $NETLOGO_TARBALL && ln -sf "NetLogo $NETLOGO_VERSION" netlogo \
&& rm -f $NETLOGO_TARBALL
#--------------ROS------------------------
#ARG FROM_IMAGE=ros:foxy
#ARG OVERLAY_WS=/opt/ros/overlay_ws
# multi-stage for caching
FROM $FROM_IMAGE AS cacher
# clone overlay source
ARG OVERLAY_WS
WORKDIR $OVERLAY_WS/src
RUN echo "\
repositories: \n\
ros2/codigo_gustavo: \n\
type: git \n\
url: https://github.com/GustavoLLima/codigo_gustavo.git \n\
version: master \n\
" > ../overlay.repos
RUN vcs import ./ < ../overlay.repos
# copy manifests for caching
WORKDIR /opt
RUN mkdir -p /tmp/opt && \
find ./ -name "package.xml" | \
xargs cp --parents -t /tmp/opt && \
find ./ -name "COLCON_IGNORE" | \
xargs cp --parents -t /tmp/opt || true
# multi-stage for building
FROM $FROM_IMAGE AS builder
# install overlay dependencies
ARG OVERLAY_WS
WORKDIR $OVERLAY_WS
COPY --from=cacher /tmp/$OVERLAY_WS/src ./src
RUN . /opt/ros/$ROS_DISTRO/setup.sh && \
apt-get update && rosdep install -y \
--from-paths \
src \
--rosdistro \
foxy \
&& rm -rf /var/lib/apt/lists/*
# build overlay source
COPY --from=cacher $OVERLAY_WS/src ./src
ARG OVERLAY_MIXINS="release"
RUN . /opt/ros/$ROS_DISTRO/setup.sh && \
colcon build \
--packages-select \
codigo_gustavo \
--mixin $OVERLAY_MIXINS
# source entrypoint setup
ENV OVERLAY_WS $OVERLAY_WS
RUN sed --in-place --expression \
'$isource "$OVERLAY_WS/install/setup.bash"' \
/ros_entrypoint.sh
#COPY --from=netlogo_cache /opt/netlogo ./netlogo
COPY --from=0 /opt/netlogo ./netlogo
Docker-compose.yml:
version: '3'
services:
talker:
build: ./
command: ros2 run codigo_gustavo talker
listener:
build: ./
environment:
- "PYTHONUNBUFFERED=1"
command: ros2 run codigo_gustavo listener
deploy:
mode: replicated
replicas: 2
modelo1:
build: ./
command: tail -f /dev/null
volumes:
- ./teste:/teste
volumes:
teste:
Error context:
cd /opt/ros/overlay_ws
./netlogo/netlogo-headless.sh --model /teste/WS2.nlogo --experiment experiment1 --spreadsheet /teste/teste2.csv
JAVA_HOME undefined, using java from path. For control over exact java version, set JAVA_HOME
./netlogo/netlogo-headless.sh: line43: java: command not found
Any ideas? What should I do? What am I doing wrong?

How to install tomcat native with oracle jdk 8

I'm trying to install oracle jdk 8 along with tomcat native with APR support on an Alpine linux docker image. I'm continually faced with the following error:
No such file or directory
#include <jni.h>
when trying to make install. I have tried using the '-I/$JAVA_HOME/ option added to the ./configure command to no avail.
This here below is my Dockerfile:
FROM alpine:latest
WORKDIR /tmp
# BASH
RUN apk add --no-cache --update-cache bash curl ca-certificates
ENV GLIBC_PKG_VERSION=2.23-r3
RUN curl -Lo /etc/apk/keys/sgerrand.rsa.pub https://raw.githubusercontent.com/sgerrand/alpine-pkg-glibc/master/sgerrand.rsa.pub
RUN curl -Lo glibc-${GLIBC_PKG_VERSION}.apk https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_PKG_VERSION}/glibc-${GLIBC_PKG_VERSION}.apk
RUN curl -Lo glibc-bin-${GLIBC_PKG_VERSION}.apk https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_PKG_VERSION}/glibc-bin-${GLIBC_PKG_VERSION}.apk
RUN curl -Lo glibc-i18n-${GLIBC_PKG_VERSION}.apk https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_PKG_VERSION}/glibc-i18n-${GLIBC_PKG_VERSION}.apk
RUN apk add glibc-${GLIBC_PKG_VERSION}.apk glibc-bin-${GLIBC_PKG_VERSION}.apk glibc-i18n-${GLIBC_PKG_VERSION}.apk
RUN /usr/glibc-compat/bin/localedef -i en_US -f UTF-8 en_US.UTF-8
# DATE
RUN apk --update add --no-cache bash tzdata && \
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone && \
apk del tzdata && \
rm -rf /var/cache
# ADD JAVA
ENV JAVA_VERSION_MAJOR=8 \
JAVA_VERSION_MINOR=73 \
JAVA_VERSION_BUILD=02 \
JAVA_PACKAGE=server-jre
# The JDK reference version / server-jre / jdk
# 8/73/02
# 7/80/15
RUN curl -jksSLH "Cookie: oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-b${JAVA_VERSION_BUILD}/${JAVA_PACKAGE}-${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-linux-x64.tar.gz" | gunzip -c - | tar -xf - && \
# apk del curl ca-certificates && \
mv jdk1.${JAVA_VERSION_MAJOR}.0_${JAVA_VERSION_MINOR}/jre /jre && \
mv jdk1.${JAVA_VERSION_MAJOR}.0_${JAVA_VERSION_MINOR}/include/linux /jre/linux && \
# rm /jre/bin/jjs && \
rm /jre/bin/keytool && \
rm /jre/bin/orbd && \
rm /jre/bin/pack200 && \
rm /jre/bin/policytool && \
rm /jre/bin/rmid && \
rm /jre/bin/rmiregistry && \
rm /jre/bin/servertool && \
rm /jre/bin/tnameserv && \
rm /jre/bin/unpack200 && \
# rm /jre/lib/ext/nashorn.jar && \
rm /jre/lib/jfr.jar && \
rm -rf /jre/lib/jfr && \
rm -rf /jre/lib/oblique-fonts && \
rm -rf /tmp/* && \
rm -rf /var/cache/* && \
echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf
ENV JAVA_HOME /jre
ENV PATH ${PATH}:${JAVA_HOME}/bin
ENV CATALINA_HOME /apache-tomcat
ENV PATH $CATALINA_HOME/bin:$PATH
RUN mkdir -p "$CATALINA_HOME"
WORKDIR $CATALINA_HOME
# let "Tomcat Native" live somewhere isolated
ENV TOMCAT_NATIVE_LIBDIR $CATALINA_HOME/native-jni-lib
ENV LD_LIBRARY_PATH ${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$TOMCAT_NATIVE_LIBDIR
RUN apk add --no-cache busybox
RUN apk add --no-cache libgcc
RUN apk add --no-cache pinentry-gtk
RUN apk add --no-cache gnupg
# see https://www.apache.org/dist/tomcat/tomcat-8/KEYS
RUN set -ex \
&& for key in \
05AB33110949707C93A279E3D3EFE6B686867BA6 \
07E48665A34DCAFAE522E5E6266191C37C037D42 \
47309207D818FFD8DCD3F83F1931D684307A10A5 \
541FBE7D8F78B25E055DDEE13C370389288584E7 \
61B832AC2F1C5A90F0F9B00A1C506407564C17A3 \
713DA88BE50911535FE716F5208B0AB1D63011C7 \
79F7026C690BAA50B92CD8B66A3AD3F4F22C4FED \
9BA44C2621385CB966EBA586F72C284D731FABEE \
A27677289986DB50844682F8ACB77FC2E86E29AC \
A9C5DF4D22E99998D9875A5110C01C5A2F6059E7 \
DCFD35E0BF8CA7344752DE8B6FB21E8933C60243 \
F3A04C595DB5B6A5F1ECA43E3B7BBB100D811BBE \
F7DA48BB64BCB84ECBA7EE6935CD23C10D498E23 \
; do \
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
done
ENV TOMCAT_MAJOR 8
ENV TOMCAT_VERSION 8.5.6
ENV TOMCAT_TGZ_URL http://archive.apache.org/dist/tomcat/tomcat-$TOMCAT_MAJOR/v$TOMCAT_VERSION/bin/apache-tomcat-$TOMCAT_VERSION.tar.gz
ENV TOMCAT_ASC_URL http://archive.apache.org/dist/tomcat/tomcat-$TOMCAT_MAJOR/v$TOMCAT_VERSION/bin/apache-tomcat-$TOMCAT_VERSION.tar.gz.asc
RUN set -x \
\
&& apk add --no-cache --virtual .fetch-deps \
ca-certificates \
tar \
openssl \
&& wget -O tomcat.tar.gz "$TOMCAT_TGZ_URL" \
&& wget -O tomcat.tar.gz.asc "$TOMCAT_ASC_URL" \
&& gpg --batch --verify tomcat.tar.gz.asc tomcat.tar.gz \
&& tar -xvf tomcat.tar.gz --strip-components=1 \
\
&& nativeBuildDir="$(mktemp -d)" \
&& tar -xvf bin/tomcat-native.tar.gz -C "$nativeBuildDir" --strip-components=1 \
&& ls -l $nativeBuildDir \
&& apk add --no-cache --virtual .native-build-deps \
apr-dev \
gcc \
libc-dev \
make \
openssl-dev \
&& ( \
export CATALINA_HOME=$PWD \
&& cd $nativeBuildDir/native \
&& ./configure \
--libdir=$TOMCAT_NATIVE_LIBDIR \
--prefix=$CATALINA_HOME \
--with-apr="$(which apr-1-config)" \
--with-java-home=$JAVA_HOME \
--with-ssl=yes \
--with-os-type=linux \
&& make -j$(getconf _NPROCESSORS_ONLN) \
&& make install \
) \
&& runDeps="$( \
scanelf --needed --nobanner --recursive "$TOMCAT_NATIVE_LIBDIR" \
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
| sort -u \
| xargs -r apk info --installed \
| sort -u \
)" \
&& apk add --virtual .tomcat-native-rundeps $runDeps \
&& apk del .fetch-deps .native-build-deps \
&& rm -rf "$nativeBuildDir" \
&& rm bin/tomcat-native.tar.gz
# verify Tomcat Native is working properly
RUN set -e \
&& nativeLines="$(catalina.sh configtest 2>&1)" \
&& nativeLines="$(echo "$nativeLines" | grep 'Apache Tomcat Native')" \
&& nativeLines="$(echo "$nativeLines" | sort -u)" \
&& if ! echo "$nativeLines" | grep 'INFO: Loaded APR based Apache Tomcat Native library' >&2; then \
echo >&2 "$nativeLines"; \
exit 1; \
fi
# Delete tomcat files
RUN rm -rf /apache-tomcat/bin/*.bat \
&& rm -rf /apache-tomcat/webapps/docs \
&& rm -rf /apache-tomcat/webapps/examples \
&& rm -rf /apache-tomcat/webapps/manager \
&& rm -rf /apache-tomcat/webapps/host-manager \
&& rm -rf /apache-tomcat/webapps/ROOT/* \
&& rm -rf /tmp/* \
&& rm -rf /var/cache/*
RUN cat /apache-tomcat/conf/server.xml
RUN echo "TEST" > /apache-tomcat/webapps/ROOT/readme.txt
# WORKDIR
WORKDIR /apache-tomcat/webapps
EXPOSE 8080 8443
#ENTRYPOINT /apache-tomcat/bin/catalina.sh run
CMD ["/bin/bash"]

I am getting error when running Dockerfile

I am getting error like find: '/opt/ibm/wlp/bin': No such file or directory when building a docker image
FROM centos:latest
RUN yum -y install wget unzip;
ENV JAVA_VERSION 1.8.0_sr5fp7
ENV LIBERTY_VERSION 17.0.0_04
RUN export BASE_URL="https://public.dhe.ibm.com/ibmdl/export/pub/systems/cloud/runtimes/java/meta/sdk/linux/x86_64/index.yml"; \
wget -q -U UA_IBM_JAVA_Docker -O /tmp/index.yml ${BASE_URL}; \
JAVA_URL=$(cat /tmp/index.yml | sed -n '/'${JAVA_VERSION}'/{n;p}' | sed -n 's/\s*uri:\s//p' | tr -d '\r'); \
wget -q -U UA_IBM_JAVA_Docker -O /tmp/ibm-java.bin ${JAVA_URL}; \
echo "INSTALLER_UI=silent" > /tmp/response.properties; \
echo "USER_INSTALL_DIR=/opt/ibm/java" >> /tmp/response.properties; \
echo "LICENSE_ACCEPTED=TRUE" >> /tmp/response.properties; \
mkdir -p /opt/ibm; \
chmod +x /tmp/ibm-java.bin; \
/tmp/ibm-java.bin -i silent -f /tmp/response.properties; \
rm -f /tmp/response.properties; \
rm -f /tmp/index.yml; \
rm -f /tmp/ibm-java.bin; \
cd /opt/ibm/java/jre/lib; \
rm -rf icc;
ENV JAVA_HOME=/opt/ibm/java/jre \
PATH=/opt/ibm/java/jre/bin:$PATH
RUN echo ${JAVA_HOME}; \
echo ${PATH};
RUN export LIB_BASE_URL="https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/downloads/wlp/index.yml"; \
wget -q -U UA-IBM-WebSphere-Liberty-Docker -O /tmp/index.yml ${LIB_BASE_URL}; \
LIBERTY_URL=$(cat /tmp/index.yml | sed -n '/'${LIBERTY_VERSION}'/{n;p}' | sed -n 's/\s*uri:\s//p' | tr -d '\r'); \
wget $LIBERTY_URL -U UA-IBM-WebSphere-Liberty-Docker -O /tmp/wlp.zip; \
unzip -q /tmp/wlp.zip -d /opt/ibm; \
rm -f /tmp/wlp.zip;
ENV PATH=/opt/ibm/wlp/bin:$PATH
LABEL "ProductID"="fbf6a96d49214c0abc6a3bc5da6e48cd"; \
"ProductName"="WebSphere Application Server Liberty"; \
"ProductVersion"="17.0.0.4";
RUN find /opt/ibm/wlp/bin -type f -exec chmod 777 {} \;
RUN /opt/ibm/wlp/bin/server create;
ADD server.xml /opt/ibm/wlp/usr/servers/defaultServer/server.xml
RUN /opt/ibm/wlp/bin/installUtility install --acceptLicense webProfile-7.0 localConnector-1.0 jndi-1.0 adminCenter-1.0 appSecurity-2.0 concurrent-1.0 \
ldapRegistry-3.0 javaMail-1.5 jdbc-4.1 jaxrs-2.0 jpa-2.1 ssl-1.0 webCache-1.0;
ADD lib /opt/ibm/wlp/usr/servers/defaultServer/lib
ADD apps /opt/ibm/wlp/usr/servers/defaultServer/apps
ADD resources /opt/ibm/wlp/usr/servers/defaultServer/resources
ADD server.xml /opt/ibm/wlp/usr/servers/defaultServer/server.xml
EXPOSE 9080
EXPOSE 9043
CMD ["/opt/ibm/wlp/bin/server", "run", "defaultServer"]
getting below message : The command '/bin/sh -c find /opt/ibm/wlp/bin -type f -exec chmod 777 {} \;' returned a non-zero code: 1
not sure what is wrong ,please help

How to install Java 9 and Gradle in a Docker image

I try to install OpenJDK9 and Gradle 4.5.1 in a Docker image.
This is my Dockerfile:
FROM ubuntu:latest
MAINTAINER Hari Sekhon (https://www.linkedin.com/in/harisekhon)
LABEL Description="Java + Ubuntu (OpenJDK)"
ENV DEBIAN_FRONTEND noninteractive
ARG JAVA_VERSION=9
ARG JAVA_RELEASE=JDK
ENV JAVA_HOME=/usr
RUN bash -c ' \
set -euxo pipefail && \
apt-get update && \
pkg="openjdk-$JAVA_VERSION"; \
if [ "$JAVA_RELEASE" = "JDK" ]; then \
pkg="$pkg-jdk-headless"; \
else \
pkg="$pkg-jre-headless"; \
fi; \
apt-get install -y --no-install-recommends "$pkg" && \
apt-get clean'
CMD /bin/bash
#install Gradle
RUN wget -q https://services.gradle.org/distributions/gradle-4.5.1-bin.zip \
&& unzip gradle-4.5.1-bin.zip -d /opt \
&& rm gradle-4.5.1-bin.zip
# Set Gradle in the environment variables
ENV GRADLE_HOME /opt/gradle-4.5.1
ENV PATH $PATH:/opt/gradle-4.5.1/bin
And I am getting an error:
ubuntu#automation-ubuntu-17:~/dockerFiles$ The command '/bin/sh -c
bash -c ' set -euxo pipefail && apt-get update &&
pkg="openjdk-$JAVA_VERSION"; if [ "$JAVA_RELEASE" = "JDK" ]; then
pkg="$pkg-jdk-headless"; else pkg="$pkg-jre-headless";
fi; apt-get install -y --no-install-recommends "$pkg" &&
apt-get clean'' returned a non-zero code: 100
The ubuntu:latest tag is currently ubuntu:18.04 (bionic), which only contains the java packages for openjdk-8-jdk-headless and openjdk-11-jdk-headless but not openjdk-9-jdk-headless (which has already reached end-of-life, at least for public updates).
openjdk-9-jdk-headless is available in ubuntu:16.04 (xenial), though.
I got the build working by switching to ubuntu:16.04, and also adding wget and unzip to the list of packages to install as they are subsequently used to download and unpack gradle but are not installed by default.
FROM ubuntu:16.04
MAINTAINER Hari Sekhon (https://www.linkedin.com/in/harisekhon)
LABEL Description="Java + Ubuntu (OpenJDK)"
ENV DEBIAN_FRONTEND noninteractive
ARG JAVA_VERSION=9
ARG JAVA_RELEASE=JDK
ENV JAVA_HOME=/usr
RUN bash -c ' \
set -euxo pipefail && \
apt-get update && \
pkg="openjdk-$JAVA_VERSION"; \
if [ "$JAVA_RELEASE" = "JDK" ]; then \
pkg="$pkg-jdk-headless"; \
else \
pkg="$pkg-jre-headless"; \
fi; \
apt-get install -y --no-install-recommends wget unzip "$pkg" && \
apt-get clean'
CMD /bin/bash
#install Gradle
RUN wget -q https://services.gradle.org/distributions/gradle-4.5.1-bin.zip \
&& unzip gradle-4.5.1-bin.zip -d /opt \
&& rm gradle-4.5.1-bin.zip
# Set Gradle in the environment variables
ENV GRADLE_HOME /opt/gradle-4.5.1
ENV PATH $PATH:/opt/gradle-4.5.1/bin

How do you disable "$HOME/.java_usagetracker" from being created?

According to Java's documentation:
https://docs.oracle.com/javacomponents/usage-tracker/overview/toc.htm#JSUTO-GUID-6642AAD5-85A1-462F-9D77-09A52DF72404
Java Usage Tracker should be disabled by default. But that is not the case for Java 8u161 or greater.
Setting com.oracle.usagetracker.track.last.usage=false in /etc/oracle/java/usagetracker.properties does the trick.
Dockerfile example:
FROM centos:7
ARG JAVA_VERSION=8u171
ARG JAVA_BUILD=b11
ARG JAVA_HASH=512cd62ec5174c3487ac17c61aaa89e8
ENV JAVA_HOME=/usr/java/default
RUN mkdir /usr/java \
&& curl --create-dirs -L --retry 2 --retry-delay 2 --connect-timeout 30 \
--cookie "oraclelicense=accept-securebackup-cookie;gpw_e24=http://edelivery.oracle.com" \
http://download.oracle.com/otn-pub/java/jdk/${JAVA_VERSION}-${JAVA_BUILD}/${JAVA_HASH}/jdk-${JAVA_VERSION}-linux-x64.rpm \
-o /tmp/jdk-linux-x64.rpm \
&& rpm -ivh /tmp/jdk-linux-x64.rpm \
&& rm -f /tmp/jdk-linux-x64.rpm \
&& mkdir -p /etc/oracle/java/ \
&& echo "com.oracle.usagetracker.track.last.usage=false" > /etc/oracle/java/usagetracker.properties

Categories

Resources