Fix #41071
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
| ... | ... |
@@ -10,13 +10,15 @@ type containerRouter struct {
|
| 10 | 10 |
backend Backend |
| 11 | 11 |
decoder httputils.ContainerDecoder |
| 12 | 12 |
routes []router.Route |
| 13 |
+ cgroup2 bool |
|
| 13 | 14 |
} |
| 14 | 15 |
|
| 15 | 16 |
// NewRouter initializes a new container router |
| 16 |
-func NewRouter(b Backend, decoder httputils.ContainerDecoder) router.Router {
|
|
| 17 |
+func NewRouter(b Backend, decoder httputils.ContainerDecoder, cgroup2 bool) router.Router {
|
|
| 17 | 18 |
r := &containerRouter{
|
| 18 | 19 |
backend: b, |
| 19 | 20 |
decoder: decoder, |
| 21 |
+ cgroup2: cgroup2, |
|
| 20 | 22 |
} |
| 21 | 23 |
r.initRoutes() |
| 22 | 24 |
return r |
| ... | ... |
@@ -497,8 +497,8 @@ func (s *containerRouter) postContainersCreate(ctx context.Context, w http.Respo |
| 497 | 497 |
hostConfig.IpcMode = container.IpcMode("shareable")
|
| 498 | 498 |
} |
| 499 | 499 |
} |
| 500 |
- if hostConfig != nil && versions.LessThan(version, "1.41") {
|
|
| 501 |
- // Older clients expect the default to be "host" |
|
| 500 |
+ if hostConfig != nil && versions.LessThan(version, "1.41") && !s.cgroup2 {
|
|
| 501 |
+ // Older clients expect the default to be "host" on cgroup v1 hosts |
|
| 502 | 502 |
if hostConfig.CgroupnsMode.IsEmpty() {
|
| 503 | 503 |
hostConfig.CgroupnsMode = container.CgroupnsMode("host")
|
| 504 | 504 |
} |
| ... | ... |
@@ -462,7 +462,7 @@ func initRouter(opts routerOptions) {
|
| 462 | 462 |
routers := []router.Router{
|
| 463 | 463 |
// we need to add the checkpoint router before the container router or the DELETE gets masked |
| 464 | 464 |
checkpointrouter.NewRouter(opts.daemon, decoder), |
| 465 |
- container.NewRouter(opts.daemon, decoder), |
|
| 465 |
+ container.NewRouter(opts.daemon, decoder, opts.daemon.RawSysInfo(true).CgroupUnified), |
|
| 466 | 466 |
image.NewRouter(opts.daemon.ImageService()), |
| 467 | 467 |
systemrouter.NewRouter(opts.daemon, opts.cluster, opts.buildkit, opts.features), |
| 468 | 468 |
volume.NewRouter(opts.daemon.VolumesService()), |