set -e 和 exec "$@" 有什么作用?为 docker 入口点脚本做些什么? [英] What does set -e and exec "$@" do for docker entrypoint scripts?

查看:77
本文介绍了set -e 和 exec "$@" 有什么作用?为 docker 入口点脚本做些什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到许多用于 docker 的 entrypoint.sh 脚本会做这样的事情:

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

#!/bin/bash
set -e

... code ...

exec "$@"

set -eexec "$@" 的作用是什么?

What are the set -e and the exec "$@" for?

推荐答案

它基本上接受传递给 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".

见:

这篇关于set -e 和 exec "$@" 有什么作用?为 docker 入口点脚本做些什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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