I have a post Shell Arguments Format
talked about exec "$@"
(当时并没有在意为什么在docker中这么使用), the script docker-entrypoint.sh
is a very common and flexible way to accept different parameters when start docker container and run application as PID 1
, this allows the application to receive any Unix signals sent to the container (之前遇到过这个问题, 非PID 1的进程在对container 的终止signal 没有反应).
See this docker best practice about entrypoint: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#entrypoint
The same pattern in envoy image, see this docker-entrypoint.sh
link:
1 |
|
For example:
1 | # start as bash |
The new thing to me is set --
, see this question:
What does “set --” do in this Dockerfile entrypoint?
The set --
command sets the positional parameters and link new tokens with existing position parameters, The --
is the standard “don’t treat anything following this as an option”,也就是说这是要排列位置参数了,而不是重置位置参数:
1 | set a b c |
Nginx Entrypoint
Let’s see one more about nginx docker entrypoint and explain:
1 |
|
Explanation: