Public | Automated Build

Last pushed: 25 days ago
Short Description
Java 8 (1.8.0_141) JDK + Maven 3.5.0 + Python 3.5.2
Full Description

Java 8 (1.8.0_141) JRE server + Maven 3.5.0 + Python 3.5.2

##Components:
Components:

  • Oracle Java "1.8.0_141" JDK environment
    Java(TM) SE Runtime Environment (build 1.8.0_141-b15)
  • Apache Maven 3.5.0
  • Other tools: git wget unzip vim python python-setuptools python-dev python-numpy

Pull the image from Docker Repository

docker pull openkbs/jre-mvn-py3

Base the image to build add-on components

FROM openkbs/jre-mvn-py3

Run the image

Then, you're ready to run:

  • make sure you create your work directory, e.g., ./data
mkdir ./data
docker run -d --name my-jre-mvn-py3 -v $PWD/data:/data -i -t openkbs/jre-mvn-py3

Build and Run your own image

Say, you will build the image "my/jre-mvn-py3".

docker build -t my/jre-mvn-py3 .

To run your own image, say, with some-jre-mvn-py3:

mkdir ./data
docker run -d --name some-jre-mvn-py3 -v $PWD/data:/data -i -t my/jre-mvn-py3

Shell into the Docker instance

docker exec -it some-jre-mvn-py3 /bin/bash

Run Python code

To run Python code

docker run -it --rm openkbs/jre-mvn-py3 python3 -c 'print("Hello World")'

or,

docker run -i --rm openkbs/jre-mvn-py3 python3 < myPyScript.py

or,

mkdir ./data
echo "print('Hello World')" > ./data/myPyScript.py
docker run -it --rm --name some-jre-mvn-py3 -v "$PWD"/data:/data openkbs/jre-mvn-py3 python3 myPyScript.py

or,

alias dpy3='docker run --rm openkbs/jre-mvn-py3 python3'
dpy3 -c 'print("Hello World")'

Compile or Run java while no local installation needed

Remember, the default working directory, /data, inside the docker container -- treat is as "/".
So, if you create subdirectory, "./data/workspace", in the host machine and
the docker container will have it as "/data/workspace".

#!/bin/bash -x
mkdir ./data
cat >./data/HelloWorld.java <<-EOF
public class HelloWorld {
   public static void main(String[] args) {
      System.out.println("Hello, World");
   }
}
EOF
cat ./data/HelloWorld.java
alias djavac='docker run -it --rm --name some-jre-mvn-py3 -v '$PWD'/data:/data openkbs/jre-mvn-py3 javac'
alias djava='docker run -it --rm --name some-jre-mvn-py3 -v '$PWD'/data:/data openkbs/jre-mvn-py3 java'

djavac HelloWorld.java
djava HelloWorld

And, the output:

Hello, World

Hence, the alias above, "djavac" and "djava" is your docker-based "javac" and "java" commands and
it will work the same way as your local installed Java's "javac" and "java" commands.
However, for larger complex projects, you might want to consider to use Docker-based IDE.
For example, try this docker-scala-ide:
Scala IDE in Docker
See also,
Java Development in Docker

Docker Pull Command
Owner
openkbs
Source Repository

Comments (0)