Logs created by build containers should be handled by the daemon, not by logging drivers.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
| ... | ... |
@@ -308,7 +308,11 @@ func workdir(b *Builder, args []string, attributes map[string]bool, original str |
| 308 | 308 |
return nil |
| 309 | 309 |
} |
| 310 | 310 |
|
| 311 |
- container, err := b.docker.ContainerCreate(types.ContainerCreateConfig{Config: b.runConfig})
|
|
| 311 |
+ container, err := b.docker.ContainerCreate(types.ContainerCreateConfig{
|
|
| 312 |
+ Config: b.runConfig, |
|
| 313 |
+ // Set a log config to override any default value set on the daemon |
|
| 314 |
+ HostConfig: &container.HostConfig{LogConfig: defaultLogConfig},
|
|
| 315 |
+ }) |
|
| 312 | 316 |
if err != nil {
|
| 313 | 317 |
return err |
| 314 | 318 |
} |
| ... | ... |
@@ -181,7 +181,11 @@ func (b *Builder) runContextCommand(args []string, allowRemote bool, allowLocalD |
| 181 | 181 |
return nil |
| 182 | 182 |
} |
| 183 | 183 |
|
| 184 |
- container, err := b.docker.ContainerCreate(types.ContainerCreateConfig{Config: b.runConfig})
|
|
| 184 |
+ container, err := b.docker.ContainerCreate(types.ContainerCreateConfig{
|
|
| 185 |
+ Config: b.runConfig, |
|
| 186 |
+ // Set a log config to override any default value set on the daemon |
|
| 187 |
+ HostConfig: &container.HostConfig{LogConfig: defaultLogConfig},
|
|
| 188 |
+ }) |
|
| 185 | 189 |
if err != nil {
|
| 186 | 190 |
return err |
| 187 | 191 |
} |
| ... | ... |
@@ -489,6 +493,8 @@ func (b *Builder) create() (string, error) {
|
| 489 | 489 |
ShmSize: b.options.ShmSize, |
| 490 | 490 |
Resources: resources, |
| 491 | 491 |
NetworkMode: container.NetworkMode(b.options.NetworkMode), |
| 492 |
+ // Set a log config to override any default value set on the daemon |
|
| 493 |
+ LogConfig: defaultLogConfig, |
|
| 492 | 494 |
} |
| 493 | 495 |
|
| 494 | 496 |
config := *b.runConfig |
| ... | ... |
@@ -1,6 +1,6 @@ |
| 1 | 1 |
package daemon |
| 2 | 2 |
|
| 3 |
-// ContainerCreateWorkdir creates the working directory. This is solves the |
|
| 3 |
+// ContainerCreateWorkdir creates the working directory. This solves the |
|
| 4 | 4 |
// issue arising from https://github.com/docker/docker/issues/27545, |
| 5 | 5 |
// which was initially fixed by https://github.com/docker/docker/pull/27884. But that fix |
| 6 | 6 |
// was too expensive in terms of performance on Windows. Instead, |
| ... | ... |
@@ -1134,6 +1134,19 @@ func (s *DockerDaemonSuite) TestDaemonLoggingDriverNoneLogsError(c *check.C) {
|
| 1134 | 1134 |
c.Assert(out, checker.Contains, expected) |
| 1135 | 1135 |
} |
| 1136 | 1136 |
|
| 1137 |
+func (s *DockerDaemonSuite) TestDaemonLoggingDriverShouldBeIgnoredForBuild(c *check.C) {
|
|
| 1138 |
+ s.d.StartWithBusybox(c, "--log-driver=splunk") |
|
| 1139 |
+ |
|
| 1140 |
+ out, err := s.d.Cmd("build")
|
|
| 1141 |
+ out, code, err := s.d.BuildImageWithOut("busyboxs", `
|
|
| 1142 |
+ FROM busybox |
|
| 1143 |
+ RUN echo foo`, false) |
|
| 1144 |
+ comment := check.Commentf("Failed to build image. output %s, exitCode %d, err %v", out, code, err)
|
|
| 1145 |
+ c.Assert(err, check.IsNil, comment) |
|
| 1146 |
+ c.Assert(code, check.Equals, 0, comment) |
|
| 1147 |
+ c.Assert(out, checker.Contains, "foo", comment) |
|
| 1148 |
+} |
|
| 1149 |
+ |
|
| 1137 | 1150 |
func (s *DockerDaemonSuite) TestDaemonUnixSockCleanedUp(c *check.C) {
|
| 1138 | 1151 |
dir, err := ioutil.TempDir("", "socket-cleanup-test")
|
| 1139 | 1152 |
if err != nil {
|