Skip to content
Advertisement

How to create docker image with nodejs 12, java, gcc, g++,python3, monocs

I am trying to dockerize my NodeJs & Express API . In my API iam using https://www.npmjs.com/package/compile-run package to compile and run C, Cpp,Java,JavaScript(Node.js env), Python languages. This package requires all 5 compilers(gcc,g++,nodejs,python3,javac) installed on the server. If any compiler misses, it throws error.

In my local(undockerized) the API is working completely fine on both windows & ubuntu(As I have installed compilers on them).

I am trying to replicate the same on my docker image. But I am stuck.

Look at my Dockerfile:

JavaScript

I think node-12 image comes along with gcc, g++,python3 and nodejs(obviously). But the issue is with java. I am not able to compile java code.

so I tried it this way

JavaScript

But I am not able to install open-jdk or open-jre with apt/apt-get. What is the right way to configure docker?

This is my nodeJS API repository https://github.com/yogendramaarisetty/online-compiler-api

Advertisement

Answer

First you must update the package list with apt-get update, then you can install openjdk-8. openjdk-11 isn’t available with that distribution of node. I used docker run -it node:12 /bin/bash to see what there was,

JavaScript

For example,

JavaScript

If you really do need Java 11, there are multiple ways and places to get openjdk-11. One is bell-sw. For example,

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement