Do not use leading slashes for paths in layer tarballs to be more compatible with docker
@@ -25,6 +25,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
+ "strings"
"syscall"
"github.com/docker/docker/pkg/archive"
@@ -74,7 +75,14 @@ func (t *Tar) AddFileToTar(p string) error {
if err != nil {
return err
}
+
+ if p != "/" {
+ // Docker uses no leading / in the tarball
+ hdr.Name = strings.TrimLeft(p, "/")
+ } else {
+ // allow entry for / to preserve permission changes etc. (currently ignored anyway by Docker runtime)
hdr.Name = p
+ }
hardlink, linkDst := t.checkHardlink(p, i)
if hardlink {
