设置-e和exec“ $ @”的原因是什么?为docker entrypoint脚本做什么? [英] What does set -e and exec "$@" do for docker entrypoint scripts?

查看:211
本文介绍了设置-e和exec“ $ @”的原因是什么?为docker entrypoint脚本做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经注意到,许多用于docker的entrypoint.sh脚本都执行以下操作:

I've noticed that many entrypoint.sh scripts for docker do something like this:

#!/bin/bash
set -e

... code ...

exec "$@"

set -e exec $ @ 吗?

推荐答案

基本上,它需要将任何传递给 entrypoint.sh的命令行参数用作参数。并将其作为命令执行。目的基本上是在此.sh脚本中执行所有操作,然后在同一shell中运行用户在命令行中传递的命令。

It basically takes any command line arguments passed to entrypoint.sh and execs them as a command. The intention is basically "Do everything in this .sh script, then in the same shell run the command the user passes in on the command line".

请参阅:

  • What are the special dollar sign shell variables?
  • Need explanations for Linux bash builtin exec command behavior

这篇关于设置-e和exec“ $ @”的原因是什么?为docker entrypoint脚本做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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