本文介绍了docker中的reexec.Init()的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在阅读docker1.8的源代码时,我发现 reexec.Init()出现在 docker.go dockerinit.go 和一些测试文件.

When reading the source code of docker1.8, I find that reexec.Init() appears in docker.go,dockerinit.go and some test files.

如果 reexec 已注册功能,则 reexec.Init()将返回 true ,以便在 docker.go 该过程将返回.

If reexec has registered functions, then reexec.Init() will return true so that in docker.go the process will return.

来自软件包 reexec README.md :

那么使用 reexec.Init()的目的是什么?

So what's the purpose of using reexec.Init()?

reexec.Init()的唯一目的是初始化Docker容器的环境吗?

Is the only purpose of reexec.Init() to init the environment of a docker container?

推荐答案

您可以从提交7321067 在docker 1.2(2014年8月)中引入了 reexec.Init():

As you can see from commit 7321067 which introduced reexec.Init() in docker 1.2 (August 2014):

这还允许将任何功能添加到docker,以便可以重新执行二进制文件并可以调用任何类型的功能.
我将在docker exec上解析的标志移到了特定的初始化器上,以使实现不会相互渗透.
这也使reexec初始化程序可以更加灵活地指定其自己的标志和选项.

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 被称为exec进程的第一部分,如果调用了初始化函数,则返回true

Init is called as the first part of the exec process and returns true if an initialization function was called

如果调用初始化程序,则docker会静默退出,而不是旧的错误消息.
以前是:

Instead of the old error message, docker silently exits if initializers are called.
Before, it was:

log.Fatal("This is a client-only binary - running it as 'dockerinit' is not supported.")

这篇关于docker中的reexec.Init()的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 05:39