Dockerfile Status 400 error

Hi, this is was my first time using docker and was trying to containerize a Spring Boot JAVA REST API using docker. I made the Dockerfile:

FROM ubuntu:latest
LABEL authors="..."
ARG JAR_FILE=target/*.jar
COPY ./target/RESTAPI-0.0.1-SNAPSHOT.jar app.jar
ENTRYPOINT ["java", "-jar", "/app.jar"]

and I installed Kali Linux and enabled the docker environment, additionally, I was able to create an image using docker. But, when I run “docker run -p 8000:8080 name-of-image” it gives me an error saying:
“docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: “java”: executable file not found in $PATH: unknown.”

… you need to use a base image that comes with pre-installed java.

It should work if you replaceFROM ubuntu:latest with FROM eclipse-temurin:17.0.6_10-jre-alpine or FROM eclipse-temurin:17.0.6_10-jre-focal (assumed you use java 17).

Hello @shauryadwivedi0108 ,
@meyay rightly explained that you need to use a base image with JDK/java installed on it.

if you have any specific need of Ubuntu then you may need to install jdk on the image below are some sample can be used with base Ubuntu image

RUN apt install openjdk-11-jre-headless  # version 11.0.11+9-0ubuntu2~20.04, or
RUN apt install default-jre              # version 2:1.11-72
RUN apt install openjdk-13-jre-headless  # version 13.0.7+5-0ubuntu1~20.04
RUN apt install openjdk-16-jre-headless  # version 16.0.1+9-1~20.04
RUN apt install openjdk-8-jre-headless   # version 8u292-b10-0ubuntu1~20.04

choose any version you want.

or choose any flavoured base image of Java you want.