GoogleContainerTools / GoogleContainerTools/jib
Using Jib CLI jar command with a quoted string in the entrypoint had surprising results
- Dominant language
- Java
- Stars
- 14.5k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Environment**:
- *Jib version:* 0.12.0
- *Build tool:* Jib CLI
- *OS:* MacOS
**Description of the issue**:
I'd like my container entrypoint to run a tiny bit of shell before running java. With a Docker build, I could set the entrypoint to something like `["/bin/sh", "-c", "do-something && exec java -jar app.jar"]` (but of course, doing a better job to forward container arguments to java). The Jib CLI's jar command seems to support quoted strings to some extent, but there may be a bug in how those strings are used down the line.
**Expected behavior**:
Running jib jar with something like `--entrypoint='/bin/sh -c "echo hello && exec java -jar app.jar"'` would result in an entrypoint equal to `["/bin/sh", "-c", "do-something && exec java -jar app.jar"]`.
**Steps to reproduce**:
```
$ jib jar main.jar --from eclipse-temurin:11-alpine --entrypoint='/bin/sh -c "echo hello && exec java -jar /app/main.jar"' --target docker://main:local)
Container entrypoint set to [/bin/sh, -c, "echo hello && exec java -jar /app/main.jar"]
Container program arguments set to []
Executing tasks:
[==============================] 100.0% complete
```
As we can see from the log line, Jib is correctly parsing three elements in the entrypoint:
```
Container entrypoint set to [/bin/sh, -c, "echo hello && exec java -jar /app/main.jar"]
```
However when running a container, it's clear that something went wrong:
```
$ docker run main:local
/bin/sh: echo hello && exec java -jar /app/main.jar: not found
```
That error is identical to running `/bin/sh -c '"echo hello && exec java -jar /app/main.jar"'` with the double quotes preserved, so it may be a quoting issue? Or it's possible I'm doing something obviously wrong here 😀
```
$ docker run -it --rm eclipse-temurin:11-alpine /bin/sh -c '"echo hello && exec java -jar /app/main.jar"'
/bin/sh: echo hello && exec java -jar /app/main.jar: not found
```
Contributor guide
Assessment
This issue has not been assessed yet.