docker image: openjdk:15: how to install python inside it - java

I want to create an image of openjdk15 and python
I am trying the Dockerfile for buid
FROM openjdk:15
RUN yum install -y oracle-epel-release-el7
RUN yum install -y python36
But when i try to build the image it shows
/bin/sh: yum: command not found
The command '/bin/sh -c yum install -y oracle-epel-release-el7' returned a non-zero code: 127
I checked the image also
$ docker run --rm -it --entrypoint "" openjdk:15 sh -c "cat /etc/os-release"
NAME="Oracle Linux Server"
VERSION="8.3"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="8.3"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Oracle Linux Server 8.3"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:8:3:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://bugzilla.oracle.com/"
ORACLE_BUGZILLA_PRODUCT="Oracle Linux 8"
ORACLE_BUGZILLA_PRODUCT_VERSION=8.3
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=8.3

It seems that yum is not available on this image. It uses microdnf as package manager. Simply use following dockerfile to install python 3.6 :
FROM openjdk:15
RUN microdnf install python36
After building and running a container with shell process I received :
bash-4.4# python3 -V
Python 3.6.8

Related

Error creating Docker container for a microservice app in Springboot in Ubuntu

I am trying to create a Docker container for a micro-service in SpringBoot Java in Ubuntu 21.10, but when I try to build the container I get this error, maybe it is a common error, but so far I can't solve it, I have checked some posts on Internet but had no luck finding a similar solution. Please I would really appreciate the help! Thank you in advance
This is my Dockerfile:
FROM ubuntu
RUN yum install -y java
VOLUME /tmp
ADD target/microservice-0.0.1-SNAPSHOT.jar app.jar
RUN sh -c 'touch /app.jar'
ENTRYPOINT ["java", "-Djava.security.egd-file:/dev/./urandom","-jar","/app.jar"]
This is the error I get:
docker build -t spring_boot_docker .
Sending build context to Docker daemon 17.72MB
Step 1/6 : FROM ubuntu
---> 54c9d81cbb44
Step 2/6 : RUN yum install -y java
---> Running in a2793e79925b
/bin/sh: 1: yum: not found
The command '/bin/sh -c yum install -y java' returned a non-zero code: 127
In ubuntu you can try installing with apt-get:
RUN apt-get update && \
apt-get install -y openjdk-8-jdk

The command `bin/sh` returned a non-zero code: 100

So I am trying to install OpenJDK in a Dockerfile but I am having issues. It always errors with the following message: Sub-process /usr/bin/dpkg returned an error code (1) and then underneath The command bin/sh returned a non-zero code: 100. This is the command that failed to execute. Currently on Ubuntu 20.04 VM
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY Folder/*.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet build -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/runtime:5.0
# Install OpenJDK-14
RUN apt-get update && \
apt-get install -y default-jdk && \
apt-get install -y ant && \
apt-get clean;
# Fix certificate issues
RUN apt-get update && \
apt-get install ca-certificates-java && \
apt-get clean && \
update-ca-certificates -f;
# Setup JAVA_HOME -- useful for docker commandline
ENV JAVA_HOME /usr/lib/jvm/default/
RUN export JAVA_HOME
RUN apt-get install -y supervisor # Installing supervisord
ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf
WORKDIR /app
COPY Folder/Lavalink/* ./
COPY --from=build-env /app/out .
#ENTRYPOINT ["dotnet", "Application.dll"]
ENTRYPOINT ["/usr/bin/supervisord"]
Here is the supervisord as well
[supervisord]
nodaemon=true
[program:folder]
command=dotnet /app/Application.dll
[program:lavalink]
command=java -jar /app/Lavalink.jar
This is a Visual Studio project written in 5.0 with a .jar file that needs to be executed.
These didn't seem to help:
apt-get update' returned a non-zero code: 100, Docker File Non-Zero Code 100 Error When Building Basically what I am trying to achieve is to install java within a container. Preferably java 13 but this issue prevents me from doing so. Last, it is important to let you know that the same commands works on another container.
Add this before installing the jdk :
RUN mkdir -p /usr/share/man/man1/
This is a problem in the debian slim images and this image is based on buster-slim. Alternatively you can try to use one of the dotnet/runtime images based on Ubuntu (5.0-focal) or Alpine (5.0-alpine).

How to use python3 inside openjdk Docker base?

I am trying to Dockerize a system where I should run bash script, which calls python3 script and then jar file. But openjdk Docker base doesn't come with python, and its container doesn't seem to support ubuntu based apt-get install commands. Any suggestions ?
You just need to use the java container based on buster instead of buster-slim. openjdk:buster
To test it run the following
docker run -it openjdk:buster /bin/bash
apt update
apt -y upgrade
apt -y install python3

Why Java is not getting installed in my docker image using Postgres docker hub image

What I would like is to add Java (installation and JAVA_HOME) in an image.
I'm using this postgres dockerfile: https://github.com/docker-library/postgres/tree/master/9.6
Which I updated with the following :
RUN apt-get -y update
RUN apt-get -y install wget
RUN apt-get -y install sudo
RUN /bin/mkdir /usr/lib/jvm
RUN wget https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz -O /tmp/openjdk-11.0.2_linux-x64_bin.tar.gz
RUN sudo tar xfvz /tmp/openjdk-11.0.2_linux-x64_bin.tar.gz --directory /usr/lib/jvm
RUN rm -f /tmp/openjdk-11.0.2_linux-x64_bin.tar.gz
ENV JAVA_HOME /etc/alternatives/jre
Please note that I'm beginner so if something is obvious for you it may not be for me.
The issue is that, /usr/lib/jvm is not created thus java is not installed and also JAVA_HOME is empty when I run the image.
When I execute manually the instructions, it works, but I would like to make my dockerfile working.

Dockerized tomcat is not starting

I am new to docker and I have tried following some tutorials and documentation on USING DOCKER TO EFFICIENTLY CREATE MULTIPLE TOMCAT INSTANCES, but am having trouble getting the service to run via the docker run command.
I have a docker file with the following coding below
FROM ubuntu:precise
MAINTAINER Quinten Krijger < qkrijger [at] gmail {dot} com>
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
RUN apt-get update && apt-get -y install python-software-properties
RUN add-apt-repository ppa:webupd8team/java
RUN apt-get update && apt-get -y upgrade
RUN echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
RUN apt-get -y install oracle-java7-installer && apt-get clean
RUN update-alternatives --display java
RUN echo "JAVA_HOME=/usr/lib/jvm/java-7-oracle" >> /etc/environment
When I build using the command
docker build -t quintenk/jdk7-oracle .
it shows the build is successful.
In the another dockerfile, I try to create create other images based on it
I have another docker in a different path with the following commands
FROM quintenk/jdk7-oracle
MAINTAINER Quinten Krijger "qkrijger#gmail.com"
RUN apt-get -y install tomcat7
RUN echo "JAVA_HOME=/usr/lib/jvm/java-7-oracle" >> /etc/default/tomcat7
EXPOSE 8080
CMD service tomcat7 start && tail -f /var/lib/tomcat7/logs/catalina.out
I use the following command to run the docker file
docker run -d quintenk/tomcat7
But it shows as tomcat instance fail
* Starting Tomcat servlet engine tomcat7
...fail!
If I give the command
docker ps
also there is no instance running on my machine
I'm obviously doing something wrong and I'm getting the behaviour on my OSX
For testing you can create a Dockerfile with CMD ["bash"].
start the container then login to the container using the command
docker -it exec container_name bash
then start tomcat and checkout out the tomcat logs
Try running the image with following command
docker run -dt --cap-add SYS_PTRACE quintenk/tomcat7
I have faced this issue. Finally, I am able to run the tomcat.Follow below steps.
Step-1: open terminal Ctrl+Alt+t
Step-2: then on terminal go inside the running container, type commands
sudo docker exec -it containerID /bin/bash
Now to check tomcat is running or not, type your container IP address followed by colon(:) 8080 port on the browser. like 172.17.0.2:8080.
Hope it helps!!

Categories

Resources