加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

“set -x”在Dockerfile中做了什么?

发布时间:2020-12-16 03:53:30 所属栏目:安全 来源:网络整理
导读:我正在学习现有的Dockerfile,开始创建自己的Dockerfile.我注意到大多数时候,命令都是从两个开始的 RUN set -x ... 要么 RUN set -ex; ... 为什么这样做,为什么这是必要的?有必要吗? 最佳答案 -e导致命令停止任何错误.更典型的语法是用和/或停止任何错误. -

我正在学习现有的Dockerfile,开始创建自己的Dockerfile.我注意到大多数时候,命令都是从两个开始的

RUN set -x ...

要么

RUN set -ex; ...

为什么这样做,为什么这是必要的?有必要吗?

最佳答案
-e导致命令停止任何错误.更典型的语法是用&&和/或停止任何错误.

-x使shell输出正在运行的每个命令.这对于调试脚本很有用.

从set下的bash手册页:

-e Exit immediately if a pipeline (which may consist of a
single simple command),a list,or a
compound command (see SHELL GRAMMAR above),exits with a non-zero status. The shell does
not exit if the command that fails is part of the command list immediately following a while
or until keyword,part of the test following the if or elif reserved words,part of any com

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读