Skip to content

Instantly share code, notes, and snippets.

@shashanthk
Created July 27, 2024 11:31
Show Gist options
  • Select an option

  • Save shashanthk/3d7dd535bf77c5ab1da18ebf72df9ddb to your computer and use it in GitHub Desktop.

Select an option

Save shashanthk/3d7dd535bf77c5ab1da18ebf72df9ddb to your computer and use it in GitHub Desktop.
Simple Docker file for Spring Boot project
## JDK
FROM eclipse-temurin:21-alpine
## container direcotry
WORKDIR /app
## copy build file from host to container
COPY target/jar-file-name.jar /app
## expose service port
EXPOSE 8080
## start service
CMD ["java", "-jar", "jar-file-name.jar"]
@shashanthk
Copy link
Copy Markdown
Author

shashanthk commented Jul 27, 2024

Keep the above file in root directory of your Spring Boot project.

To build Docker image, execute the below command:

docker build -t <your_docker_image_name> .

To create a container out of it

docker run -p 8080:8080 <your_docker_image_name>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment