Docker cannot find the jar file

I’m creating an docker image file for the jar file that I have to further use it in the Kubernetes cluster.

The image builds up but when I run this image as container, it fails with error
Error: Unable to access jarfile <–filename>

If I run the same image with -it option it runs as a container and the file is present in the filesystem of the container, but I doubt it this really a solution

docker run --name adaptercont1 -it adapterjar:1.0 /bin/bash

Dockerfile

FROM openjdk:25-jdk-slim

RUN mkdir /usr/src/adapterpod

WORKDIR /adapterpod

COPY myjarfile-24.01.00.003.jar /usr/src/adapterpod/

CMD ["java", "-jar", "/usr/src/adapterpod/myjarfile-24.01.00.003.jar -m localhost -Port 3000 -Key myKey -podTenant Java -podName MyPOD"]

This seems strange. Workdir is inside container.

Why would you expect this to work?

A short look in the docs should have made clear why it fails: https://docs.docker.com/reference/dockerfile/#cmd

You are using the exec form wrong. If you had shared the actual error message, it would have been obvious right away, because what you replace with <-filename> actually was /usr/src/adapterpod/myjarfile-24.01.00.003.jar -m localhost -Port 3000 -Key myKey -podTenant Java -podName MyPOD. Of course, Java is not able to find a jar with that name. You need to split each parameter into its own string, like shown in the docs.