Docker Java Application Example
- Create a folder
2. Create a Java Fileclass DockerTest{
public static void main(String[] args){
System.out.println("This is docker java ");
}
}
3. Create a DockerFileFROM java:8
COPY . /var/www/java
WORKDIR /var/www/java
RUN javac DockerTest.java
CMD ["java", "DockerTest"]
4. Bulid a docker image by command
Usage : docker build -t java-app .
- 5. Run the docker image by command
Usage :docker run java-app