diff --git a/api/server/httputils/write_log_stream.go b/api/server/httputils/write_log_stream.go index 5f9e43f585..1f33a3351d 100644 --- a/api/server/httputils/write_log_stream.go +++ b/api/server/httputils/write_log_stream.go @@ -11,10 +11,13 @@ import ( "github.com/docker/docker/api/types/backend" "github.com/docker/docker/api/types/container" "github.com/docker/docker/pkg/ioutils" - "github.com/docker/docker/pkg/jsonmessage" "github.com/docker/docker/pkg/stdcopy" ) +// rfc3339NanoFixed is time.RFC3339Nano with nanoseconds padded using zeros to +// ensure the formatted time isalways the same number of characters. +const rfc3339NanoFixed = "2006-01-02T15:04:05.000000000Z07:00" + // WriteLogStream writes an encoded byte stream of log messages from the // messages channel, multiplexing them with a stdcopy.Writer if mux is true func WriteLogStream(_ context.Context, w http.ResponseWriter, msgs <-chan *backend.LogMessage, config *container.LogsOptions, mux bool) { @@ -53,7 +56,7 @@ func WriteLogStream(_ context.Context, w http.ResponseWriter, msgs <-chan *backe logLine = append(logLine, msg.Line...) } if config.Timestamps { - logLine = append([]byte(msg.Timestamp.Format(jsonmessage.RFC3339NanoFixed)+" "), logLine...) + logLine = append([]byte(msg.Timestamp.Format(rfc3339NanoFixed)+" "), logLine...) } if msg.Source == "stdout" && config.ShowStdout { _, _ = outStream.Write(logLine)