code: func snapshotPath(path, containerID, tempDir string, client *docker.Client) (string, error) {
  	f, err := ioutil.TempFile(tempDir, "archived-path")
  	if err != nil {
  		return "", err
  	}
  	glog.V(4).Infof("Snapshot %s for later use under %s", path, f.Name())
  
  	r, w := io.Pipe()
  	tr := tar.NewReader(r)
  	tw := tar.NewWriter(f)
  	go func() {
  		err := filterTarPipe(tw, tr, func(h *tar.Header) bool {
  			if i := strings.Index(h.Name, "/"); i != -1 {
  				h.Name = h.Name[i+1:]
  			}
  			return len(h.Name) > 0
  		})
  		if err == nil || err == io.EOF {
  			tw.Flush()
  			w.Close()
  			glog.V(5).Infof("Snapshot rewritten from %s", path)
  			return
  		}
  		glog.V(5).Infof("Snapshot of %s failed: %v", path, err)
  		w.CloseWithError(err)
  	}()
  
  	if !strings.HasSuffix(path, "/") {
  		path += "/"
  	}
  	err = client.DownloadFromContainer(containerID, docker.DownloadFromContainerOptions{
  		Path:         path,
  		OutputStream: w,
  	})
  	f.Close()
  	if err != nil {
  		os.Remove(f.Name())
  		return "", err
  	}
  	return f.Name(), nil
  }
docs: // snapshotPath preserves the contents of path in container containerID as a temporary
  // archive, returning either an error or the path of the archived file.