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/*
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.
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
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.
I am not sure why I expected this to work:
# Dockerfile
FROM node:6
FROM java:8
but it doesn't really work - looks like the first command is ignored, and second command works.
Is there a straightforward way to install both Node.js and Java in a Docker container?
Ultimately the problem I am trying to solve is that I am getting an ENOENT error when running Selenium Webdriver -
[20:38:50] W/start - Selenium Standalone server encountered an error: Error: spawn java ENOENT
And right now I assume it's because Java is not installed in the container.
The best way for you is to take java (which is officially deprecated and it suggests you use openjdk image) and install node in it.
So, start with
FROM openjdk:latest
This will use the latest openjdk image, which is 8u151 at this time. Then install node and other dependencies you might need:
RUN apt-get install -y curl \
&& curl -sL https://deb.nodesource.com/setup_9.x | bash - \
&& apt-get install -y nodejs \
&& curl -L https://www.npmjs.com/install.sh | sh
You might want to install things like grunt afterwards, so this might come in handy as well.
RUN npm install -g grunt grunt-cli
In total you will get the following Dockerfile:
FROM openjdk:latest
RUN apt-get install -y curl \
&& curl -sL https://deb.nodesource.com/setup_9.x | bash - \
&& apt-get install -y nodejs \
&& curl -L https://www.npmjs.com/install.sh | sh \
RUN npm install -g grunt grunt-cli
You may clone the Dockerfile from my gitlab repo here
You can use single FROM per generated image.
Try to use node as a base image and install java to it.
Dockerfile
FROM node:latest
RUN apt-get -y install default-jre
You can choose the version you need:
apt install default-jre
apt install openjdk-11-jre-headless
apt install openjdk-8-jre-headless
You can also use the node image and then install the default-jre:
# Dockerfile
FROM node:latest
RUN apt-get -y install default-jre
You can choose the version you need:
apt install default-jre
apt install openjdk-11-jre-headless
apt install openjdk-8-jre-headless
Perhaps, you might want to try this https://hub.docker.com/r/timbru31/java-node one to create the docker file.
This docker image comes with both Java and Node pre-installed. It comes in handy when both are required as a dependency.
Something like,
FROM timbru31/java-node:<tag>
The FROM inside your dockerfile simply tells docker from which image it should start the configuration. You can't simply concatenate multiple images together. There are already multiple container images available which offer preinstalled Java 8 and node JS. I don't want to recommend any image specifically but will direct you to docker-hub for you to go search on your own and use the container that suites your needs the best.
With version 14 of node it works perfectly for me:
FROM openjdk:latest
RUN apt-get install -y curl \
&& curl -sL https://deb.nodesource.com/setup_14.x | bash - \
&& apt-get install -y nodejs \
&& curl -L https://www.npmjs.com/install.sh | sh \
RUN npm install -g grunt grunt-cli
this worked for me:
FROM openjdk:16-slim-buster
RUN apt-get update; apt-get install -y curl \
&& curl -sL https://deb.nodesource.com/setup_14.x | bash - \
&& apt-get install -y nodejs \
&& curl -L https://www.npmjs.com/install.sh | sh
This works for me with node v16.15.0, be careful with the packages version of java, I'm using the latest by default. The packages used for java are:
Java Runtime Environment (jre)
Java Development Kit (jdk)
FROM node:16.15.0
RUN apt-get update \
&& apt-get install default-jre -y \
&& apt-get install default-jdk -y
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
RUN npm install --global nodemon
COPY . .
EXPOSE 3000
CMD ["npm", "run", "dev"]
I hope this works for you all