我发现daemon通过这些代码创建了一个容器
// NewBaseContainer creates a new container with its
// basic configuration.
func NewBaseContainer(id, root string) *Container {
return &Container{
CommonContainer: CommonContainer{
ID: id,
State: NewState(),
ExecCommands: exec.NewStore(),
Root: root,
MountPoints: make(map[string]*volume.MountPoint),
StreamConfig: runconfig.NewStreamConfig(),
attachContext: &attachContext{},
},
}
}
它看起来像创建一个实例,但只是一些配置。我不知道它在哪里调用libcontainer来创建真正的容器
这段代码实际上来自container/container.go
。
你必须回到docker 1.9.0才能发现这些代码实际上仍然在daemon/daemon_windows.go
使用libcontainerd设置一个新的守护进程,以便创建实际的容器(在docker 1.10或更高版本中)