From 4570cfd3ba900253c18066a0299d64551dbf85cc Mon Sep 17 00:00:00 2001 From: "Stefan J. Wernli" Date: Thu, 17 Mar 2016 17:48:21 -0700 Subject: [PATCH] Fixing logs file handle leak. Docker logs was only closing the logger when the HTTP response writer received a close notification, however in non-follow mode the writer never receives a close. This means that the daemon would leak the file handle to the log, preventing the container from being removed on Windows (file in use error). This change explicitly closes the log when the end of stream is hit. Signed-off-by: Stefan J. Wernli --- daemon/logs.go | 1 + 1 file changed, 1 insertion(+) diff --git a/daemon/logs.go b/daemon/logs.go index 8172df175c..40c47a6eff 100644 --- a/daemon/logs.go +++ b/daemon/logs.go @@ -84,6 +84,7 @@ func (daemon *Daemon) ContainerLogs(containerName string, config *backend.Contai case msg, ok := <-logs.Msg: if !ok { logrus.Debugf("logs: end stream") + logs.Close() return nil } logLine := msg.Line