Java Application configuration with Ubuntu Image
299
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Building the image from the Dockerfile
Now that we have written a Dockerfile, we can build the corresponding Docker image.
To build the image, start with the following command:
$ docker build -f Dockerfile -t demo/oracle-java:8 .
Testing the Image
Create a project folder and then create a file called Main.java inside this folder with following content: public class Main { public static void main(String[] args) { System.out.println("Hello, World"); }
} Now execute the following commands from the current project directory. To compile your Main.java file.
$ docker run --rm -v $PWD:/app -w /app demo/oracle-java:8 javac Main.java To run your compiled Main.class file. $ docker run --rm -v $PWD:/app -w /app demo/oracle-java:8 java Main
Hello, World output should be displayed. tutorial : https://runnable.com/docker/java/dockerize-your-java-application
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| For More informations please contact : [email protected] |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Content type
Image
Digest
Size
282.1 MB
Last updated
about 9 years ago
docker pull wissemmahjoub/java8