Skip to content

Docker with Java

Somkiat Puisungnoen edited this page Nov 2, 2017 · 2 revisions

Docker images

Example

public class Hello {
  public static void main(String... args) {
    System.out.println("Hello World");
  }
}

Run java with Docker

Compile java

docker container run --rm -v $(pwd):/somkiat/src \
 -w /somkiat/src \
 openjdk:8u131-jdk-alpine \
 javac Hello.java

Run java

docker container run --rm -v $(pwd):/somkiat/src \
 -w /somkiat/src \
 openjdk:8u131-jdk-alpine \
 java Hello
Clone this wiki locally