How to run kurento java web server on docker - java

I want to run this kurento example: https://doc-kurento.readthedocs.io/en/stable/tutorials/java/tutorial-one2one.html
But I have some issues with application server when I building it on docker.
When I run kms docker - it run's successfully. I setted port of kurento-media-server as 8889:8888 and IP in docker container when I checked was 172.17.0.2. Also, I setted port of web app as 8081:8080.
When i tried to open a web-page - it was not responded.
My url was: https://192.168.0.2:8443, where 192.168.0.2 is IP of my server where I run docker. Also I tried to connect to docker container IP directly with https://172.17.0.3:8443.
Here's my app dockerfile.
FROM ubuntu:16.04
MAINTAINER USER1 "USER1#infinte.com"
RUN apt-get update
RUN apt-get install git -y
RUN apt-get install curl -y
RUN apt install apt-utils -y
RUN apt install maven -y
RUN apt install openjdk-8-jdk openjdk-8-jre -y
RUN apt-get install software-properties-common -y
RUN git clone https://github.com/Kurento/kurento-tutorial-java.git
WORKDIR kurento-tutorial-java/kurento-one2one-call-advanced/
EXPOSE 8080
ENTRYPOINT mvn -U clean spring-boot:run -Dkms.url=ws://172.17.0.2:8888/kurento
Here's my kms run command:
docker run -t --name kms -p 8889:8888 kurento/kurento-media-server
Here's my app server run command:
docker run -d --name apps -p 8081:8080 --link kms apps
What mistakes I have made here? May'be I need to change IP in ENTRYPOINT?

I spent many weeks to find out the reason why it's not working.
To make everything work, I needed to add --network=host line in docker command.
Correct docker command is
docker run --network=host -t --name apps -p 8081:8080 apps

Related

Can't connect to X11 window server using ':0' error when building Docker image on EC2

I'm attempting to build a Docker image to provision this software: https://fragpipe.nesvilab.org/docs/tutorial_setup_fragpipe.html
This is my Dockerfile in its current state:
FROM amazonlinux:2022
ENV DISPLAY=:0
ENV JAVA_HOME=/usr/lib/jvm/java-17-amazon-corretto.x86_64
COPY FragPipe-19.0.zip .
COPY MSFragger-20171106.zip .
RUN yum update -y \
&& yum upgrade -y \
&& yum install -y unzip java-17-amazon-corretto
RUN rpmkeys --import "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF" \
&& curl https://download.mono-project.com/repo/centos8-stable.repo | tee /etc/yum.repos.d/mono-centos8-stable.repo \
&& yum install -y mono-devel
RUN unzip MSFragger-20171106.zip \
&& rm MSFragger-20171106.zip
RUN unzip FragPipe-19.0.zip \
&& rm FragPipe-19.0.zip
RUN fragpipe/bin/fragpipe
However, for hours now I've run into errors like this:
Exception in thread "main" java.awt.AWTError: Can't connect to X11 window server using ':0' as the value of the DISPLAY variable.
I've tried multiple fixes, including using the official AWS corretto Docker image amazoncorretto:17-al2022-RC-headful, and manually installing the Java system dependencies. However, I continue to get this error.
Before I spend any more time troubleshooting this, I'm curious if the fact that I'm running this on EC2 has any effect on whether or not X11 will work?

japp.jar is not found when building docker image

I'm very much new to docker. I have a node application that process/read a java file. I'm trying to create a docker image that runs node and java. I node configs are working well but I'm always getting errors when building the docker file because of java - it shows
failed to compute cache key: "/japp.jar" not found: not found"
My Dockerfile contains:
FROM node:14.18.1
RUN apt-get update && apt-get -y upgrade
WORKDIR /code
EXPOSE 8443
COPY package.json /code/package.json
RUN npm install
COPY . /code
# Jave Config
FROM eclipse-temurin:11
RUN mkdir /opt/app
COPY japp.jar /opt/app
ENTRYPOINT ["java", "-jar", "/opt/app/japp.jar"]
CMD ["node","app.js"]
I was trying to follow the docs here but no luck.
In the past, I was using the following for Java config and that was working fine, but it shows some vulnerability so I need to switch to eclipse-temurin:11
# RUN echo 'deb http://ftp.debian.org/debian stretch-backports main' | tee /etc/apt/sources.list.d/stretch-backports.list
# RUN apt-get update && apt-get -y upgrade && \
# apt-get install -y openjdk-11-jre-headless && \
# apt-get clean;

How to install package manager in java based docker image

I am developing an application using SpringBoot and Java with Docker.
I want to install Netcat in my application so that I can check if a specific container is up before my spring application starts.
I have tried
RUN apt-get update && apt-get -y install netcat && apt-get clean
But it says apt-get is not found.
I am not sure how can I install any package manager in my java based application.
Or is there any other I can get net-cat installed.
Below is my Dockerfile
FROM openjdk:8
RUN apt-get update && apt-get -y install netcat && apt-get clean
ADD target/student.jar student.jar
EXPOSE 2018
ENTRYPOINT ["java","-jar","student.jar"]
apt-get is package manager for Debian-based Linux distros (including Ubuntu and others).
Try apk add instead.
Also, if you are using package managers in your Dockerfile, it is considered a good practice to explicitly specify Linux distro. In your case you can use openjdk:8-jdk-stretch variant or any other, where distro is specified.
I can get a successful docker build with this Dockerfile
FROM openjdk:8
RUN apt-get update && apt-get -y install netcat && apt-get clean
ENTRYPOINT ["/bin/bash"]
and apt-get works just fine. As far as I can tell openjdk:8 is Ubuntu (or at least Debian based). Even if I run
docker build . -t stackexample
docker run -it stackexample
and get inside the container, running netcat opens the netcat cmd.

How to Create a Dockerfile file using Rhel

I am creating google cloud VM using rhel7 and install docker after try to build docker image using dockerfile image not build docker.
FROM rhel
RUN yum update -y
yum install -y \
java-1.8.0-openjdk \
java-1.8.0-openjdk-devel
ENV JAVA_HOME /etc/alternatives/jre
Error response from daemon: Unknown instruction: .
You can use,
FROM registry.access.redhat.com/rhel7/rhel
MAINTAINER John W. Jones <jjones#example.com>
# Add Web server, update image, and clear cache
RUN yum -y install httpd && yum -y update; yum clean all
# Add some data to web server
RUN echo "This Web server is working." > /var/www/html/index.html
EXPOSE 80
ENTRYPOINT [ "/usr/sbin/httpd" ]
CMD [ "-D", "FOREGROUND" ]
(ref.)

Install MySQL connector/J in Docker container

I'm deploying an application to a pre-configured GlassFish Docker container on Elastic Beanstalk. I need to install the MySQL connector/J library so it's accessible to GlassFish. According to the AWS documentation, "With preconfigured Docker platforms you cannot use a configuration file to customize and configure the software that your application depends on." But it does state: "you can add a Dockerfile to your application's root folder."
They provide an example (with no explanation!) on installing a PostgreSQL library for Python but I'm using Java and MySQL. As I am completely unfamiliar with Docker (and really just need to configure this one thing), I can't figure out how to do it. Using Amazon's example Dockerfile I was able to come up with this:
FROM amazon/aws-eb-glassfish:4.1-jdk8-onbuild-3.5.1
# Exposes port 8080
EXPOSE 8080 3306
# Install MySQL dependencies
RUN curl -L -o /tmp/mysql-connector-java-5.1.34.jar https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.34/mysql-connector-java-5.1.34.jar && \
apt-get update && \
apt-get install -y /tmp/mysql-connector-java-5.1.34.jar libpq-dev && \
rm -rf /var/lib/apt/lists/*
However, on application deploy, I'm getting the following error:
t update && apt-get install -y /tmp/mysql-connector-java-5.1.34.jar libpq-dev && rm -rf /var/lib/apt/lists/*] returned a non-zero code: 100"
And obviously, my library is not installed. How can I install the MySQL Connector/J library with a Dockerfile?
apt-get install -y /tmp/mysql-connector-java-5.1.34.jar
This is not how apt-get works. It installs debian packages.
There is a package called libmysql-java that may be what you want.
You might also try something like
RUN curl -L -o /mysql-connector-java-5.1.34.jar https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.34/mysql-connector-java-5.1.34.jar
ENV CLASSPATH=/mysql-connector-java-5.1.34.jar:${CLASSPATH}

Categories