Home > Net >  How do you finalize a docker container such that it passes args directly to an executable?
How do you finalize a docker container such that it passes args directly to an executable?

Time:01-27

For example, I have an executable cli that I want to run when I type docker run -t foo called foo-cli:

docker run -it foo "bash"
$: foo-cli --help
yay it works

And:

docker run -t foo "foo-cli" "--help"
yay it works

How do I set docker up so that I can write:

docker run -t foo "--help"

And have it output:

yay it works

???

I have tried a variety of commands such as:

CMD ["bash", "foo-cli"]
$: docker run -t foo "--help"
docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "--help": executable file not found in $PATH: unknown.

CodePudding user response:

Simply specify the executable as the entrypoint:

ENTRYPOINT ["foo-cli"]

you don't need to specify a default cmd, since as you mentioned that will be passed at container run time.

  • Related