Prevent loop with var overshadowing

Incase of a 3xx redirect the var was being overshowed and ever changed
causing an infinite loop.

Fixes #9480

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Refactor put image function's redirect loop

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Merge pull request #9604 from crosbymichael/registry-fruit-loops

Prevent infinite loop with var overshadowing
Fetch and truncate container logs.

Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
Add docs for fetch and truncate logs.

Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
Use new filewriter package for logging to disk.

This allows for safe log truncation.

filewriter is an io.WriteCloser.  It takes a file path on initializing,
and proxies all writes through an io.Pipe(). When truncation occurs, the
file is closed, causing the proxying to stop, meanwhile the
writer end is still accepting writes. After truncation is completed it
re-opens the file and starts proxying those writes again.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>