Create Docker container with both Java and Node.js Create Docker container with both Java and Node.js selenium selenium

Create Docker container with both Java and Node.js


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:latestRUN 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:latestRUN apt-get -y install default-jre

You can choose the version you need:

apt install default-jreapt install openjdk-11-jre-headlessapt install openjdk-8-jre-headless


You can also use the node image and then install the default-jre:

# DockerfileFROM node:latestRUN apt-get -y install default-jre

You can choose the version you need:

apt install default-jreapt install openjdk-11-jre-headlessapt install openjdk-8-jre-headless