DockerFile to run a java program

前端 未结 8 1527
礼貌的吻别
礼貌的吻别 2021-02-19 16:10

Hi I\'m new to Docker and trying out to write a new image from the scratch. I am writing this dockerFile to compile and run a simple java program available in the same directory

8条回答
  •  庸人自扰
    2021-02-19 16:31

    FROM java:8

    WORKDIR /
    
    ADD HelloWorld.java HelloWorld.java
    
    CMD javac HelloWorld.java
    
    ADD HelloWorld.class HelloWorld.class
    
    CMD java Test
    

    Update the above details in your Dockerfile the rebuild the docker image and run.

提交回复
热议问题