Error in JDK installation in ubuntu docker - java

I have a docker file like below.
FROM ubuntu
FROM python:3.6
RUN apt-get update --fix-missing
RUN apt-get install wget curl software-properties-common -y
RUN apt-get install g++ gcc mercurial -y
RUN apt-get update && \
apt-get install -y openjdk-8-jdk && \
apt-get install -y ant && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /var/cache/oracle-jdk8-installer;
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
RUN export JAVA_HOME
When i try to build the docker using sudo docker build -t test_dock . command, there is an error saying
Unable to locate jdk package
So i have added
RUN add-apt-repository ppa:openjdk-r/ppa
before jdk installation command.
Now the build errors out saying
E: The repository 'http://ppa.launchpad.net/openjdk-r/ppa/ubuntu focal
Release' does not have a Release file.
What is the correct way to install jdk in ubuntu docker?

For me solved by replacing :
FROM ubuntu
FROM python:3.6
To:
FROM python:3-stretch

Related

How to install font on linux

I am using windows os, So there is no issue with Font(java.awt) class object creation. but my testing environment is on linux. So on that I am getting NULL POINTER exception.
Cannot load from short array because "sun.awt.FontConfiguration.head" is null
After seacrhing I found that there should be fonts folder in usr/share directory on linux.
So someone can please suggest. Do I have to just copy fonts to that directory or there is other way to intsall?
For my configuration (java.18/Spring Boot/jib/Docker/ubuntu) I've used this these commands for resolving the issue:
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
RUN apt-get update -y
RUN apt-get install -y apt-utils --no-install-recommends
RUN apt-get install -y libfreetype6 --no-install-recommends
RUN apt-get install -y fontconfig --no-install-recommends
RUN apt-get install -y fonts-dejavu --no-install-recommends

How to install java in an airflow container using docker-compose.yaml

I am using this docker-compose.yaml file to run airflow on docker container.
https://airflow.apache.org/docs/apache-airflow/2.0.2/docker-compose.yaml
I need to install JRE in one of the containers. How do I add instruction to add java to the docker-compose.yaml file?
Try the following:
Create the following Dockerfile in the directory where you also have the docker-compose.yml:
FROM apache/airflow:2.0.2
USER root
# Install OpenJDK-11
RUN apt update && \
apt-get install -y openjdk-11-jdk && \
apt-get install -y ant && \
apt-get clean;
# Set JAVA_HOME
ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64/
RUN export JAVA_HOME
USER airflow
WORKDIR /app
COPY requirements.txt /app
RUN pip install --trusted-host pypi.python.org -r requirements.txt
In order to install packages via apt, you have to switch to root user. Later, we switch back to user airflow. The specification of the working directory and the installation of python packages through requirements.txt might not apply, depending on your case.
Then, in your docker-compose.yml, add build: . after &airflow-common.
Finally, build your pipeline using docker-compose up -d --build.
For more information, look here: https://airflow.apache.org/docs/docker-stack/build.html#building-the-image
You have to build your own airflow image.
In your Dockerfile you have to apt install the airflow and export JAVA_HOME.
Dockerfile example:
FROM apache/airflow:2.5.1
USER root
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
openjdk-11-jre-headless \
&& apt-get autoremove -yqq --purge \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
USER airflow
ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
RUN pip install --no-cache-dir apache-airflow-providers-apache-spark==2.1.3
Build command example:
docker build -t airflow-with-java .
After successfully image building edit your docker-compose by replacing airflow image:
x-airflow-common:
&airflow-common
image: ${AIRFLOW_IMAGE_NAME:-airflow-with-java}
More information you can look here: https://airflow.apache.org/docs/docker-stack/build.html

How to install java 8 using dockerfile in python:3.8-slim-buster base image

Below is my Dockerfile
FROM python:3.8-slim-buster
WORKDIR /app
RUN python --version
RUN apt-get install java-1.8.0-openjdk-devel
RUN python -m pip install --upgrade pip
RUN pip install --default-timeout=100 pyspark
I want to install java 8 and set JAVA_HOME variables. But when I am trying to build above image I am getting below error:
E: Unable to locate package java-1.8.0-openjdk-devel
E: Couldn't find any package by glob 'java-1.8.0-openjdk-devel'
E: Couldn't find any package by regex 'java-1.8.0-openjdk-devel'
This is my first attempt in creating a docker image. Please suggest what is wrong with above Dockerfile. I am working on centos7.
Another approach is that you can build your Dockerfile based on FROM ubuntu:20.04 where Python 3.8 is set as default (here). Then, install java and pip later.
FROM ubuntu:20.04
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
RUN apt-get update -y \
&& apt-get install -y software-properties-common \
&& add-apt-repository ppa:deadsnakes/ppa \
&& apt-get install openjdk-8-jdk -y \
&& apt-get install python3-pip -y \
&& export JAVA_HOME \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Cannot Install openjdk-7-jdk with dockerfile from Ubuntu14.04

As in title, I can not install openjdk-7-jdk using dockerfile from Ubuntu 14.04.
At that command RUN apt-get install -y openjdk-7-jdk I get the following error
Unable to fetch some archives, maybe run apt-get update or try with
--fix-missing?
failed to build: The command '/bin/sh -c apt-get install -y
openjdk-7-jdk' returned a non-zero code: 100
Before I already use RUN apt-get update -y && apt-get upgrade -y and additionally I was trying RUN sudo apt-get -f install. I read that people find a way to do this using Packages in the PPA, but it's not recommended because of the lack of security.

Docker phusion/baseimage install oracle_db

Can someone help me install oracle_db client on my existing docker image. I tried so hard to get around a fix for this issue. Looks impossible to install oracle_db with phusion/baseimage.
My dockerfile is this:
FROM phusion/baseimage
MAINTAINER bugsbunny
RUN echo "deb http://archive.ubuntu.com/ubuntu trusty main universe" > /etc/apt/sources.list
RUN add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe"
RUN apt-get -y update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -q python-software-properties software-properties-common
ENV JAVA_VER 8
ENV JAVA_HOME /usr/lib/jvm/java-8-oracle
RUN echo 'deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main' >> /etc/apt/sources.list && \
echo 'deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main' >> /etc/apt/sources.list && \
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C2518248EEA14886 && \
apt-get update && \
echo oracle-java${JAVA_VER}-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && \
apt-get install -y --force-yes --no-install-recommends oracle-java${JAVA_VER}-installer oracle-java${JAVA_VER}-set-default && \
apt-get clean && \
rm -rf /var/cache/oracle-jdk${JAVA_VER}-installer
RUN update-java-alternatives -s java-8-oracle
RUN echo "export JAVA_HOME=/usr/lib/jvm/java-8-oracle" >> ~/.bashrc
RUN apt-get install nano
RUN apt-get install -y ksh
RUN echo "deb http://cz.archive.ubuntu.com/ubuntu trusty main" > /etc/apt/sources.list
RUN apt-get update
RUN cd /home/ && wget http://launchpadlibrarian.net/333072908/libaio1_0.3.110-4_amd64.deb && dpkg -i libaio1_0.3.110-4_amd64.deb
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ADD mtf-release /home/mtf-release
ADD instantclient_12_2 /opt/oracle/instantclient_12_2
RUN sh -c "echo /opt/oracle/instantclient_12_2 > /etc/ld.so.conf.d/oracle-instantclient.conf" && ldconfig
RUN export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2:$LD_LIBRARY_PATH
RUN mkdir -p /opt/oracle/instantclient_12_2/network/admin
RUN export PATH=/opt/oracle/instantclient_12_2:$PATH
#ENTRYPOINT ["/usr/bin/python"]
As you can see, I need java:8 version and oracle_db client, sqlplus to make my docker work. Is there any proper docker image which has java + oracledb or anyway to merge two docker images into one so that I have both installed working fine.? Thank you.
Can someone help me with using two FROMs and what all images i need?
So you want a Docker image that container both oracle client and java.
Oracle provides a Docker image for the instant client and the source code for the Docker file can be found here.
For Java there are many Docker images available such as openjdk.
You can merge the two images using Docker multi-stage builds. Before that make sure to login into docker store, go to oracle instantclient image, and accept the license and pull the image docker pull store/oracle/database-instantclient:12.2.0.1
FROM store/oracle/database-instantclient:12.2.0.1 as oracle
FROM openjdk:8-jdk
COPY --from=oracle /usr/lib/oracle /usr/lib/oracle
ENV PATH=$PATH:/usr/lib/oracle/12.2/client64/bin
Once you build the above dockerfile you will have a docker image containing java and oracle instantclient.

Categories

Resources