什么是shell形式和exec形式? [英] What are shell form and exec form?

查看:416
本文介绍了什么是shell形式和exec形式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是命令的shell形式和exec形式?

我仔细阅读了几个文档,以清楚地了解shell形式和exec形式。但是所有人都对我感到困惑。任何人都可以帮助找出这两种形式之间的区别吗?


PS :尽管我在查阅docker文件说明时遇到了这些术语(例如:RUN,CMD,ENTRYPOINT ),我想知道它们之间的一般区别,而不是在Docker上下文中。

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.

推荐答案

docker shell语法(只是 RUN ENTRYPOINT CMD )将运行该字符串作为 / bin / sh -c 的参数。这使您可以使用Shell来扩展变量,子命令,管道输出,链接命令以及其他Shell便利。

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

exec语法只是运行包含的args提供的二进制文件,但是没有任何功能外壳解析。在docker中,您可以使用json格式的数组来表明这一点。

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"]

exec语法的优点是从启动的进程中删除了shell,这可能会抑制信号处理。在shell语法中使用 / bin / sh -c 重新格式化命令可能还会破坏入口点和cmd的串联。

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.

这篇关于什么是shell形式和exec形式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆