When using the official GraalVM Native Image, I am getting "Error: Unrecognized option: -c" for every shell script

I want to build a GraalVM Java Native Image. I am using the official GraalVM Native Image as my GitLab CI/CD job image. I am using GitLab CI/CD on GitLab.com

When I run any shell command (even echo "test") inside the ghcr.io/graalvm/native-image:java17 job image, I am getting this error:

Error: Unrecognized option: -c

My GitLab CI/CD pipeline looks like this:

build:
  image: ghcr.io/graalvm/native-image:java17
  script:
    - echo "test"

When I use the same image within a Dockerfile, no error occurs:

FROM ghcr.io/graalvm/native-image:java17
RUN echo "test"

What does GitLab CI/CD do differently here? How can I get rid of this error?

Hi @johnson.henrity

I think your Docker container probably has a default ENTRYPOINT that you don’t need. You can change this in your YAML file like this:

test:
  stage: test
  image:
    name: ghcr.io/graalvm/native-image:java17
    entrypoint:
      - ""
  script:
    - echo "test"

which gives me:

...
Using docker image sha256:d344988f87aeb0628254eb0f317686dddce2d4ebd8b7bafd9ba7b3181e4e32ac for ghcr.io/graalvm/native-image:java17 with digest ghcr.io/graalvm/native-image@sha256:ce0d805e1daf74e41cd0256296d09c7ec10b2c0c560fadd7bfadbb5e9523b475 ...
$ echo "test"
test
Cleaning up project directory and file based variables
Job succeeded
1 Like

Thank you very much. :slightly_smiling_face: That worked!

1 Like