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?

  • ASP.NET Core 1.0 EF7 System.Data.SqlClient not found
  • Unknown Blob when pulling microsoft/xxxxx
  • Restrict system calls inside docker container
  • Docker run error: could not create session key: too many links
  • Docker Compose networking: hostnames in nginx not resolving
  • Docker set ipaddress and start services
  • Equivalent to boot2docker ip for new docker for windows10/hyperV
  • Docker's --memory switch does not work as expected
  • node.js in a dockerfile cant connect to mongolabs via mongoose: getaddrinfo ESRCH
  • IBM Containers: cf ic login failing
  • memory and cpu management on docker containers
  • How is Vagrant an advantage over boot2docker? [closed]
  • 2 Solutions collect form web for “Dockerizing java app”

    This article shows you step by step how to accomplish it.

    https://blog.giantswarm.io/getting-started-with-java-development-on-docker/

    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:

    https://github.com/dchqinc/event-sourcing-microservices

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.