简体   繁体   中英

docker run with port-forward fails

This is my docker file

FROM openjdk:8-jre-slim

RUN mkdir /app

COPY dept-1.0.jar /app

CMD java -jar /app/dept-1.0.jar

EXPOSE 8080

The docker image can be run without any issues if I were to run like without port-forward docker run --name=department dept:latest

But with port-forward docker run --name=department dept:latest -p 8082:8080 I see this error -

docker: Error response from daemon: OCI runtime create failed: container_linux.go:345: starting container process caused "exec: \"-p\": executable file not found in $PATH": unknown.

Can someone help pls?

I changed the following in the Dockerfil

CMD java -jar /app/dept-1.0.jar

to

ENTRYPOINT ["java", "-jar", "/app/dept-1.0.jar"]

This solved my issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM