In my case, I’ll do this with a .jar file (a Java app) (the location of .jar is in the root directory, search: /build/libs/)
You must create a file called “Dockerfile” with the following content:
# Usamos una imagen de Java ligera
FROM eclipse-temurin:21-jdk-alpine
# Directorio de trabajo dentro del contenedor
WORKDIR /app
# Copiamos el jar generado (asegúrate de que el nombre coincida)
COPY ./*.jar app.jar
# Exponemos el puerto de Spring Boot
EXPOSE 7000
# Comando para arrancar la app
ENTRYPOINT ["java", "-jar", "app.jar"]
The EXPOSE 7000 line is for informational purposes only; it does not serve any functional purpose (it’s like a comment)
The COPY command copies the .jar file of the Java app (./*.jar) (the location of .jar) to the destination location (app.jar) (create the output file called app.jar)
create the docker image, with the command (in same location that the file Dockerfile):
docker build -t my-image-name .
You will see something like this:

View all the images you have:
docker images

Docker manages the images; I don’t know where they are stored
create a docker container and run it, the docker container has the docker image:
docker run -d -p 8090:8090 --name my-container-spring mi-app-custom
docker run: It’s 3 commands in 1 single command (docker pull if does not exist locally, docker create, docker start)
the springboot java gradle app runs in the port 8090
I mapped between the host (8090) and the docker container created (8090): -p 8090:8090