shlogg · Early preview
Shakhzhakhan Maxudbek @xinitd

Docker Tutorial For Java Devs: Fast Deployment & Multi-OS Support

Create Java app in Docker: create directory, Main.java file, Dockerfile with FROM openjdk and RUN javac Main.java, then build image with docker build and run it with docker run.

Docker is good solution when you want to fast deploying your applications and run in different operating systems. You don't need to install your application's runtime anywhere. Just install Docker and run anything you want. Docker build image for your application with all dependencies inside.
In this tutorial I show you how to create new Java application and run it in Docker.
Start with creating directory for project:

mkdir myproject && cd myproject

    
    

    
    




Create Main.java file with this code:

class Main {
    public static void main(String[] args) {
        System.out.pri...