What are shell form and exec form of commands? I have gone through several documents to get a clear idea of shell form and exec form. But all looked confusing to me. Can anyone help to figure out what are the difference between these two form?
PS: Although I came across these terms while I was going through the docker file instructions(ex: RUN, CMD, ENTRYPOINT), I want to know the difference between them in general, not in docker context.
The docker shell syntax (which is just a string as the
CMD) will run that string as the parameter to
/bin/sh -c. This gives you a shell to expand variables, sub commands, piping output, chaining commands together, and other shell conveniences.
RUN ls * | grep $trigger_filename || echo file missing && exit 1
The exec syntax simply runs the binary you provide with the args you include, but without any features of the shell parsing. In docker, you indicate this with a json formatted array.
RUN ["/bin/app", "arg1", "arg2"]
The advantage of the exec syntax is removing the shell from the launched process, which may inhibit signal processing. The reformatting of the command with
/bin/sh -c in the shell syntax may also break concatenation of your entrypoint and cmd together.