mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
validate log-opt when creating containers
Signed-off-by: Shijiang Wei <mountkin@gmail.com>
This commit is contained in:
parent
3f4e49aa61
commit
7285c9a53a
2 changed files with 14 additions and 0 deletions
|
@ -5,6 +5,7 @@ import (
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/docker/docker/container"
|
"github.com/docker/docker/container"
|
||||||
|
"github.com/docker/docker/daemon/logger"
|
||||||
"github.com/docker/docker/image"
|
"github.com/docker/docker/image"
|
||||||
"github.com/docker/docker/layer"
|
"github.com/docker/docker/layer"
|
||||||
"github.com/docker/docker/pkg/idtools"
|
"github.com/docker/docker/pkg/idtools"
|
||||||
|
@ -80,6 +81,11 @@ func (daemon *Daemon) create(params types.ContainerCreateConfig) (retC *containe
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
logCfg := container.GetLogConfig(daemon.defaultLogConfig)
|
||||||
|
if err := logger.ValidateLogOpts(logCfg.Type, logCfg.Config); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
if err := daemon.setSecurityOptions(container, params.HostConfig); err != nil {
|
if err := daemon.setSecurityOptions(container, params.HostConfig); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -440,3 +440,11 @@ func (s *DockerSuite) TestCreateWithWorkdir(c *check.C) {
|
||||||
dockerCmd(c, "create", "--name", name, "-w", dir, "busybox")
|
dockerCmd(c, "create", "--name", name, "-w", dir, "busybox")
|
||||||
dockerCmd(c, "cp", fmt.Sprintf("%s:%s", name, dir), prefix+slash+"tmp")
|
dockerCmd(c, "cp", fmt.Sprintf("%s:%s", name, dir), prefix+slash+"tmp")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *DockerSuite) TestCreateWithInvalidLogOpts(c *check.C) {
|
||||||
|
name := "test-invalidate-log-opts"
|
||||||
|
_, _, err := dockerCmdWithError("create", "--name", name, "--log-opt", "invalid=true")
|
||||||
|
c.Assert(err, checker.NotNil)
|
||||||
|
out, _ := dockerCmd(c, "ps", "-a")
|
||||||
|
c.Assert(out, checker.Not(checker.Contains), name)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue