Consider the command:
ls [OPTION]... [FILE]...
Options come first, and then comes the file. However, somehow, I have no idea why, ls does not insists on this order. Therefore ls -la /home and ls /home -la produce identical output.
We can use this quirk to send options to a ls that knows its [FILE] argument.
FROM ubuntu:22.04
ENTRYPOINT ["ls", "/home"]
Then passing arguments is the same as passing options:
$ docker build -t test .
$ docker run test
$ docker run test -la
total 8
drwxr-xr-x 2 root root 4096 Apr 18 10:28 .
drwxr-xr-x 1 root root 4096 May 12 16:58 ..
However some programs insist on the order of options and arguments. For instance a .jar with a Spring server application:
This works as intended:
java -jar -Dspring.profiles.active=ci backend.jar
This does not:
java -jar backend.jar -Dspring.profiles.active=ci
The [COMMAND] and [ARG...] in docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...] seem to be appended to the entrypoint and not inserted.
Is there any way to pass options instead of arguments to a docker ENTRYPOINT?