0% found this document useful (0 votes)
2 views1 page

Java App with Dockerfile Setup

This document outlines a simple Java application using a single-stage Dockerfile. It includes the project structure, the Java source code, and the Dockerfile commands for building and running the app. The approach is suitable for small applications or testing, with no external dependencies required.

Uploaded by

Pooja A S
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Java App with Dockerfile Setup

This document outlines a simple Java application using a single-stage Dockerfile. It includes the project structure, the Java source code, and the Dockerfile commands for building and running the app. The approach is suitable for small applications or testing, with no external dependencies required.

Uploaded by

Pooja A S
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Simple Java App with Single-Stage Dockerfile

Project Structure
my-java-app/
├── Dockerfile
└── src/
└── [Link]

1. src/[Link]
public class App {
public static void main(String[] args) {
[Link]("Hello from Java inside Docker!");
}
}

2. Dockerfile
FROM eclipse-temurin:17-jdk-alpine

WORKDIR /app

COPY src/ .

RUN javac [Link]

CMD ["java", "App"]

Build and Run Commands


docker build -t java-simple-app .
docker run java-simple-app

Notes
- This approach is good for small apps or testing/demo.
- No external libraries or dependencies are used (just standard Java).
- If you need multiple classes or packages, you can update the structure accordingly.

You might also like