Merge pull request #28098 from yongtang/25099-oom_score_adj-empty-env

Fix `/proc/<pid>/oom_score_adj: invalid argument` error caused by empty env name
Upstream-commit: c025049c27c2cc8a6f1f978769c89a1fdf07a6f3
Component: engine
This commit is contained in:
Vincent Demeester
2016-11-09 10:39:18 +01:00
committed by GitHub
4 changed files with 72 additions and 0 deletions

View File

@ -15,6 +15,7 @@ import (
"github.com/docker/docker/pkg/signal"
"github.com/docker/docker/pkg/system"
"github.com/docker/docker/pkg/truncindex"
"github.com/docker/docker/runconfig/opts"
"github.com/docker/go-connections/nat"
)
@ -232,6 +233,13 @@ func (daemon *Daemon) verifyContainerSettings(hostConfig *containertypes.HostCon
return nil, fmt.Errorf("invalid hostname format: %s", config.Hostname)
}
}
// Validate if Env contains empty variable or not (e.g., ``, `=foo`)
for _, env := range config.Env {
if _, err := opts.ValidateEnv(env); err != nil {
return nil, err
}
}
}
if hostConfig == nil {