docker 中 reexec.Init() 的目的是什么?
What's the purpose of reexec.Init() in docker?
在阅读docker1.8的源码时,发现reexec.Init()出现在docker.go
,dockerinit.go
和一些测试文件。
如果reexec
有注册函数,那么reexec.Init()会returntrue
所以在docker.go
该过程将 return.
来自软件包 reexec
的 README.md
:
The reexec
package facilitates the busybox style reexec of the docker binary that we require because
of the forking limitations of using Go.
那么使用reexec.Init()的目的是什么?
reexec.Init() 的唯一目的是初始化 docker 容器的环境吗?
正如您在 docker 1.2(2014 年 8 月)中引入 reexec.Init()
的 commit 7321067 所见:
This changes the way the exec drivers work by not specifing a -driver
flag on reexec.
For each of the exec drivers they register their own functions that will be matched against the argv 0 on exec and called if they match.
This also allows any functionality to be added to docker so that the binary can be reexec'd and any type of function can be called.
I moved the flag parsing on docker exec to the specific initializers so that the implementations do not bleed into one another.
This also allows for more flexability within reexec initializers to specify their own flags and options.
Init
is called as the first part of the exec process and returns true if an initialization function was called
如果调用初始值设定项,docker 会静默退出,而不是旧的错误消息。
之前是:
log.Fatal("This is a client-only binary - running it as 'dockerinit' is not supported.")
在阅读docker1.8的源码时,发现reexec.Init()出现在docker.go
,dockerinit.go
和一些测试文件。
如果reexec
有注册函数,那么reexec.Init()会returntrue
所以在docker.go
该过程将 return.
来自软件包 reexec
的 README.md
:
The
reexec
package facilitates the busybox style reexec of the docker binary that we require because of the forking limitations of using Go.
那么使用reexec.Init()的目的是什么?
reexec.Init() 的唯一目的是初始化 docker 容器的环境吗?
正如您在 docker 1.2(2014 年 8 月)中引入 reexec.Init()
的 commit 7321067 所见:
This changes the way the exec drivers work by not specifing a
-driver
flag on reexec.
For each of the exec drivers they register their own functions that will be matched against the argv 0 on exec and called if they match.This also allows any functionality to be added to docker so that the binary can be reexec'd and any type of function can be called.
I moved the flag parsing on docker exec to the specific initializers so that the implementations do not bleed into one another.
This also allows for more flexability within reexec initializers to specify their own flags and options.
Init
is called as the first part of the exec process and returns true if an initialization function was called
如果调用初始值设定项,docker 会静默退出,而不是旧的错误消息。
之前是:
log.Fatal("This is a client-only binary - running it as 'dockerinit' is not supported.")