Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 29 additions & 9 deletions router/pump.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ func ignoreContainer(container *docker.Container) bool {
return false
}

func hasJsonFile(container *docker.Container) bool {
return container.HostConfig.LogConfig.Type == "json-file"
}

type update struct {
*docker.APIEvents
pump *containerPump
Expand Down Expand Up @@ -143,15 +147,31 @@ func (p *LogsPump) pumpLogs(event *docker.APIEvents, backlog bool) {
p.update(event)
debug("pump:", id, "started")
go func() {
err := p.client.Logs(docker.LogsOptions{
Container: id,
OutputStream: outwr,
ErrorStream: errwr,
Stdout: true,
Stderr: true,
Follow: true,
Tail: tail,
})
var err error
// Log drivers other than 'json-file' will not support the /logs API
if hasJsonFile(container) {
debug("pump:", id, "using /logs")
err = p.client.Logs(docker.LogsOptions{
Container: id,
OutputStream: outwr,
ErrorStream: errwr,
Stdout: true,
Stderr: true,
Follow: true,
Tail: tail,
})
} else {
debug("pump:", id, "using /attach")
err = p.client.AttachToContainer(docker.AttachToContainerOptions{
Container: id,
OutputStream: outwr,
ErrorStream: errwr,
Stdout: true,
Stderr: true,
Logs: false,
Stream: true,
})
}
if err != nil {
debug("pump:", id, "stopped:", err)
}
Expand Down