What are shell form and exec form?

后端 未结 2 731
日久生厌
日久生厌 2020-12-15 21:57

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. C

2条回答
  •  生来不讨喜
    2020-12-15 22:16

    The docker shell syntax (which is just a string as the RUN, ENTRYPOINT, and 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.

    The entrypoint documentation does a good job covering the various scenarios and explaining this in more detail.

提交回复
热议问题