This project demonstrates how to containerize a simple Java "Hello World" application using Docker. It includes two versions:
- A standalone Dockerized Java app.
- A Docker Compose setup for container orchestration.
hello_world_dockerfile/ # Standalone Docker setup
|- Dockerfile # Dockerfile to build the Java app image
|- pom.xml # Maven build file
|- src/ # Java source code
|- target/ # Compiled output
docker-compose/ # Docker Compose version
|- docker-compose.yml # Defines service(s) and image build
|- Dockerfile # Dockerfile to build the Java app image
|- pom.xml, src/, target/ # Same as above
- Docker
- Docker Compose (only for compose version)
- Java JDK 8+
- Maven
-
Navigate to the folder:
cd hello_world_dockerfile
-
Build the Maven project:
mvn clean package
-
Build the Docker image:
docker build -t hello-world-java .
-
Run the Docker container:
docker run --rm hello-world-java
-
Navigate to the folder:
cd docker-compose
-
Build and start the services:
docker-compose up --build
-
To stop:
docker-compose down
You should see something like:
Hello, World from Java!
This project is for educational purposes.
Feel free to customize the app further or integrate with other services using Docker Compose!