mint
mint copied to clipboard
Add environment variables to set inactivity timeout values
Fixes-###
What
When I use mint (slim) to optimize my docker image (original size is 13 GB), I always get this error
level=error msg="dockerutil.CopyFromContainer: dclient.DownloadFromContainer() error = inactivity time exceeded timeout"
And slim optimization failed finally with error
cmd=slim info=build.error status='optimized.image.build.error' error='no layers'
Why
The reason is the inactivity timeout is hardcoded to 20secs for export image and download from container
options := dockerapi.ExportImageOptions{
Name: imageRef,
OutputStream: dfile,
InactivityTimeout: 20 * time.Second,
}
downloadOptions := dockerapi.DownloadFromContainerOptions{
Path: remote,
OutputStream: dfile,
InactivityTimeout: 20 * time.Second,
InactivityTimeout: downloadTimeoutValue * time.Second,
}
For large docker image, we might need longer time to finish these operation.
In order to fix that, we add two environment variables SLIM_EXPORT_IMAGE_INACTIVITY_TIMEOUT and SLIM_DOWNLOAD_INACTIVITY_TIMEOUT to set the inactivity timeout values respectively.
How Tested
Now we can run mint slim with the customized timeout value like
SLIM_DOWNLOAD_INACTIVITY_TIMEOUT=180 mint slim ...