Tools, FAQ, Tutorials:
Build My Java Image with "openjdk"
How to build My Java Docker Image with "openjdk"
✍: FYIcenter.com
If you want build your own Java Docker image with "openjdk",
you can following this tutorial.
1. Create a Java program, Hello.java:
C:\fyicenter> type Hello.java
class Hello {
public static void main(String[] a) {
System.out.println("Hello world!");
}
}
2. Create a docker file, JavaImage:
C:\fyicenter> type JavaImage FROM openjdk COPY Hello.java . RUN javac Hello.java ENTRYPOINT java -cp . Hello
3. Build a new Docker image:
C:\fyicenter> docker build --file JavaImage --tag myjava . Sending build context to Docker daemon 12.87MB Step 1/4 : FROM openjdk ---> fdc7d8d04bc9 Step 2/4 : COPY Hello.java . ---> 69c39511a38b Step 3/4 : RUN javac Hello.java ---> Running in 255db47b55d3 Removing intermediate container 255db47b55d3 ---> 49c58badc583 Step 4/4 : ENTRYPOINT java -cp . Hello ---> Running in f96e3591f800 Removing intermediate container f96e3591f800 ---> 9e2719b56d7c Successfully built 9e2719b56d7c Successfully tagged myjava:latest
4. Run the new Docker image:
C:\fyicenter> docker run --name myjava myjava Hello world!
5. Remove the container, so we can run it again.
C:\fyicenter> docker rm myjava myjava
Ok, we are able to build our own Java Docker image with "openjdk".
Note that how we copied Hello.java from local host to the container and compile it there.
⇒ Path Name Used to Build Windows Images
⇐ "openjdk" Docker Image for Windows
2021-11-30, ∼1339🔥, 0💬
Popular Posts:
How to build a PHP script to dump Azure AD 2.0 Authentication Response? If you are use the Azure-AD-...
How to add request URL Template Parameters to my Azure API operation to make it more user friendly? ...
How to use the JSON to XML Conversion Tool at utilities-online.info? If you want to try the JSON to ...
How to access Query String parameters from "context.Request.Url.Que ry"object in Azure API Policy? Q...
How To Remove Slashes on Submitted Input Values in PHP? By default, when input values are submitted ...