Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -705,7 +705,7 @@ func buildRouters(opts routerOptions) []router.Router {
|
| 705 | 705 |
routers := []router.Router{
|
| 706 | 706 |
// we need to add the checkpoint router before the container router or the DELETE gets masked |
| 707 | 707 |
checkpointrouter.NewRouter(opts.daemon), |
| 708 |
- container.NewRouter(opts.daemon, opts.daemon.RawSysInfo()), |
|
| 708 |
+ container.NewRouter(opts.daemon), |
|
| 709 | 709 |
image.NewRouter( |
| 710 | 710 |
opts.daemon.ImageService(), |
| 711 | 711 |
opts.daemon.RegistryService(), |
| ... | ... |
@@ -6,6 +6,7 @@ import ( |
| 6 | 6 |
|
| 7 | 7 |
containerpkg "github.com/docker/docker/daemon/container" |
| 8 | 8 |
"github.com/docker/docker/daemon/server/backend" |
| 9 |
+ "github.com/docker/docker/pkg/sysinfo" |
|
| 9 | 10 |
"github.com/moby/go-archive" |
| 10 | 11 |
"github.com/moby/moby/api/types/container" |
| 11 | 12 |
"github.com/moby/moby/api/types/filters" |
| ... | ... |
@@ -68,6 +69,10 @@ type commitBackend interface {
|
| 68 | 68 |
CreateImageFromContainer(ctx context.Context, name string, config *backend.CreateImageConfig) (imageID string, err error) |
| 69 | 69 |
} |
| 70 | 70 |
|
| 71 |
+type sysInfoProvider interface {
|
|
| 72 |
+ RawSysInfo() *sysinfo.SysInfo |
|
| 73 |
+} |
|
| 74 |
+ |
|
| 71 | 75 |
// Backend is all the methods that need to be implemented to provide container specific functionality. |
| 72 | 76 |
type Backend interface {
|
| 73 | 77 |
commitBackend |
| ... | ... |
@@ -77,4 +82,5 @@ type Backend interface {
|
| 77 | 77 |
monitorBackend |
| 78 | 78 |
attachBackend |
| 79 | 79 |
systemBackend |
| 80 |
+ sysInfoProvider |
|
| 80 | 81 |
} |
| ... | ... |
@@ -1,22 +1,17 @@ |
| 1 | 1 |
package container |
| 2 | 2 |
|
| 3 |
-import ( |
|
| 4 |
- "github.com/docker/docker/daemon/server/router" |
|
| 5 |
- "github.com/docker/docker/pkg/sysinfo" |
|
| 6 |
-) |
|
| 3 |
+import "github.com/docker/docker/daemon/server/router" |
|
| 7 | 4 |
|
| 8 | 5 |
// containerRouter is a router to talk with the container controller |
| 9 | 6 |
type containerRouter struct {
|
| 10 | 7 |
backend Backend |
| 11 |
- sysInfo *sysinfo.SysInfo |
|
| 12 | 8 |
routes []router.Route |
| 13 | 9 |
} |
| 14 | 10 |
|
| 15 | 11 |
// NewRouter initializes a new container router |
| 16 |
-func NewRouter(b Backend, sysInfo *sysinfo.SysInfo) router.Router {
|
|
| 12 |
+func NewRouter(b Backend) router.Router {
|
|
| 17 | 13 |
r := &containerRouter{
|
| 18 | 14 |
backend: b, |
| 19 |
- sysInfo: sysInfo, |
|
| 20 | 15 |
} |
| 21 | 16 |
r.initRoutes() |
| 22 | 17 |
return r |
| ... | ... |
@@ -498,7 +498,7 @@ func (c *containerRouter) postContainersCreate(ctx context.Context, w http.Respo |
| 498 | 498 |
name := r.Form.Get("name")
|
| 499 | 499 |
|
| 500 | 500 |
// TODO(thaJeztah): do we prefer [backend.ContainerCreateConfig] here? |
| 501 |
- req, err := runconfig.DecodeCreateRequest(r.Body, c.sysInfo) |
|
| 501 |
+ req, err := runconfig.DecodeCreateRequest(r.Body, c.backend.RawSysInfo()) |
|
| 502 | 502 |
if err != nil {
|
| 503 | 503 |
return err |
| 504 | 504 |
} |
| ... | ... |
@@ -547,7 +547,7 @@ func (c *containerRouter) postContainersCreate(ctx context.Context, w http.Respo |
| 547 | 547 |
|
| 548 | 548 |
if versions.LessThan(version, "1.41") {
|
| 549 | 549 |
// Older clients expect the default to be "host" on cgroup v1 hosts |
| 550 |
- if !c.sysInfo.CgroupUnified && hostConfig.CgroupnsMode.IsEmpty() {
|
|
| 550 |
+ if hostConfig.CgroupnsMode.IsEmpty() && !c.backend.RawSysInfo().CgroupUnified {
|
|
| 551 | 551 |
hostConfig.CgroupnsMode = container.CgroupnsModeHost |
| 552 | 552 |
} |
| 553 | 553 |
} |