Dockerizing java app
I’m a beginner in docker and I have one question. I have downloaded boot2docker which is running on oracle virtual box. When I did ssh on boot2docker and created a directory where I keep my simple app in java (file with code with .java extension is enough? ). How should I include that directory in Dockerfile to create the image I want and then run this app on docker?
If I manage with all of that, should I install Java on that image right?
2 Solutions collect form web for “Dockerizing java app”
This article shows you step by step how to accomplish it.
As others have said, you will need to add or copy your Java file(s) using the Dockerfile. This is well documented on Docker Hub: https://hub.docker.com/_/java/
Here’s an example for a Dockerfile:
FROM java:7 COPY . /usr/src/myapp WORKDIR /usr/src/myapp RUN javac Main.java CMD ["java", "Main"]
The java container is perfect for running JAR files in a microservices architecture — if you’ve already built the JAR file. You can check out this example: