Skip to content

CodvaTech-Labs/Online-Book-Library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Certainly! Below are the steps you can include in your README.md to guide users on building the Docker image and running the Docker container:

# Dockerizing a Spring Boot Application

This repository contains a Dockerfile to package a Spring Boot application as a Docker container. The Dockerfile uses the official OpenJDK runtime as its parent image.

## Usage

### Build Docker Image

To build the Docker image, follow these steps:

1. Open a terminal and navigate to the directory containing the Dockerfile.

2. Run the following command to build the Docker image:

    ```bash
    docker build -t my-spring-app .
    ```

   Replace `my-spring-app` with your desired image name.

### Run Docker Container

After building the Docker image, you can run the Docker container using the following steps:

1. Run the Docker container with the following command:

    ```bash
    docker run -p 8080:8080 my-spring-app
    ```

   This command maps port 8080 from the container to port 8080 on the host machine. Adjust the port mappings as needed based on your application configuration.

2. Once the Docker container is running, you can access the Spring Boot application by navigating to [http://localhost:8080](http://localhost:8080) in your web browser.

## Dockerfile Explanation

```Dockerfile
# Use an official OpenJDK runtime as a parent image
FROM openjdk

# Set the working directory in the container
WORKDIR /app

# Copy the application JAR file into the container at /app
COPY target/Menu-Driven-0.0.1-SNAPSHOT.jar /app/

# Specify the command to run on container startup
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "Menu-Driven-0.0.1-SNAPSHOT.jar"]
  • FROM openjdk: Uses the official OpenJDK runtime as the base image.
  • WORKDIR /app: Sets the working directory inside the container to /app.
  • COPY target/Menu-Driven-0.0.1-SNAPSHOT.jar /app/: Copies the application JAR file into the container at the specified directory.
  • EXPOSE 8080: Exposes port 8080 to the host machine.
  • ENTRYPOINT ["java", "-jar", "Menu-Driven-0.0.1-SNAPSHOT.jar"]: Specifies the command to run on container startup.

Make sure to provide clear instructions and any additional details that might be relevant to your specific application or use case.

About

This is for Online Book Library Project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors 2

  •  
  •