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?

  • Docker node flow-bin not found (gitlab ci)
  • Jenkins + Docker
  • How to check the configuration of an app deployed on docker container
  • Docker best practice scaling
  • I am trying to connect multiple docker containers and host machines to a consul server using weave network
  • Tomcat hosted on centos:centos7 docker container, can't view webpage outside of container
  • Can docker containers within same host have same ports
  • Restrict published port to a specific container with Docker
  • Fetching git behind proxy in docker container
  • How to expose port from host to container in Docker?
  • Docker portability issues with locally saved images
  • How to create a virtual cluster using docker on a single node?
  • 2 Solutions collect form web for “Dockerizing java app”

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

    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:

    Here’s an example for a Dockerfile:

        FROM java:7
        COPY . /usr/src/myapp
        WORKDIR /usr/src/myapp
        RUN javac
        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:

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