Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8-jre-alpine CMD java not found #94

Closed
artheus opened this issue Jan 30, 2017 · 2 comments
Closed

8-jre-alpine CMD java not found #94

artheus opened this issue Jan 30, 2017 · 2 comments

Comments

@artheus
Copy link

artheus commented Jan 30, 2017

There seems to be a problem with the alpine images. At least there is for me.
I also tried the deprecated java:8-jre-alpine image and got the same result.

Dockerfile:

FROM openjdk:8-jre-alpine
ARG FINALNAME
ADD /$FINALNAME /$FINALNAME
CMD ["java", "-jar", $FINALNAME]

(Do not worry about the FINALNAME argument, that works as it should, my problem is the CMD line)

Run command:

artheus# docker run -it 106738dc2d2e
/bin/sh: [java,: not found

I have tried it with both docker 1.12 and 1.13.

I've tried running a container from my image specifying the command myself.

artheus# docker run -it 106738dc2d2e java -jre my-application-0.0.1-SNAPSHOT.jar
*** Runs perfectly ***
@artheus
Copy link
Author

artheus commented Jan 30, 2017

I also tried cleaning out the cache of images and containers on my machines completely, but the issue still persists.

@tianon
Copy link
Member

tianon commented Jan 30, 2017

The problem is your $FINALNAME argument -- ["java", "-jar", $FINALNAME] is not valid JSON, so it's passed to the shell as-is, and that's why your error message references [java, as the command that's not found (it's being passed to the shell). If you must have that final argument come from an environment variable, you'll have to switch to the shell syntax, although using exec can ensure that java still ends up being the only thing running:

CMD exec java -jar "$FINALNAME"

@artheus artheus closed this as completed Jan 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants