1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #29552 from dnephin/fix-build-with-log-driver

Ignore the daemon log config when building images
This commit is contained in:
Daniel Nephin 2017-02-07 15:47:41 -05:00 committed by GitHub
commit 1b4e2b7c87
5 changed files with 28 additions and 3 deletions

View file

@ -49,6 +49,8 @@ var BuiltinAllowedBuildArgs = map[string]bool{
"no_proxy": true,
}
var defaultLogConfig = container.LogConfig{Type: "none"}
// Builder is a Dockerfile builder
// It implements the builder.Backend interface.
type Builder struct {

View file

@ -308,7 +308,11 @@ func workdir(b *Builder, args []string, attributes map[string]bool, original str
return nil
}
container, err := b.docker.ContainerCreate(types.ContainerCreateConfig{Config: b.runConfig})
container, err := b.docker.ContainerCreate(types.ContainerCreateConfig{
Config: b.runConfig,
// Set a log config to override any default value set on the daemon
HostConfig: &container.HostConfig{LogConfig: defaultLogConfig},
})
if err != nil {
return err
}

View file

@ -181,7 +181,11 @@ func (b *Builder) runContextCommand(args []string, allowRemote bool, allowLocalD
return nil
}
container, err := b.docker.ContainerCreate(types.ContainerCreateConfig{Config: b.runConfig})
container, err := b.docker.ContainerCreate(types.ContainerCreateConfig{
Config: b.runConfig,
// Set a log config to override any default value set on the daemon
HostConfig: &container.HostConfig{LogConfig: defaultLogConfig},
})
if err != nil {
return err
}
@ -489,6 +493,8 @@ func (b *Builder) create() (string, error) {
ShmSize: b.options.ShmSize,
Resources: resources,
NetworkMode: container.NetworkMode(b.options.NetworkMode),
// Set a log config to override any default value set on the daemon
LogConfig: defaultLogConfig,
}
config := *b.runConfig

View file

@ -1,6 +1,6 @@
package daemon
// ContainerCreateWorkdir creates the working directory. This is solves the
// ContainerCreateWorkdir creates the working directory. This solves the
// issue arising from https://github.com/docker/docker/issues/27545,
// which was initially fixed by https://github.com/docker/docker/pull/27884. But that fix
// was too expensive in terms of performance on Windows. Instead,

View file

@ -1134,6 +1134,19 @@ func (s *DockerDaemonSuite) TestDaemonLoggingDriverNoneLogsError(c *check.C) {
c.Assert(out, checker.Contains, expected)
}
func (s *DockerDaemonSuite) TestDaemonLoggingDriverShouldBeIgnoredForBuild(c *check.C) {
s.d.StartWithBusybox(c, "--log-driver=splunk")
out, err := s.d.Cmd("build")
out, code, err := s.d.BuildImageWithOut("busyboxs", `
FROM busybox
RUN echo foo`, false)
comment := check.Commentf("Failed to build image. output %s, exitCode %d, err %v", out, code, err)
c.Assert(err, check.IsNil, comment)
c.Assert(code, check.Equals, 0, comment)
c.Assert(out, checker.Contains, "foo", comment)
}
func (s *DockerDaemonSuite) TestDaemonUnixSockCleanedUp(c *check.C) {
dir, err := ioutil.TempDir("", "socket-cleanup-test")
if err != nil {