The latest Docker uses go 1.7.5 (https://github.com/moby/moby/blob/master/CHANGELOG.md#contrib-1), in which the archive/tar package has a bug that cannot handle file paths longer than 100 characters (https://github.com/golang/go/issues/17630). As a result, Docker will generate images containing ill-formed tar files (details below) when there are long paths. Docker itself understands the ill-formed image fine, but a standard tar program will interpret the image as if all files with long paths are placed under the root directory (https://github.com/moby/moby/issues/29360).
This bug has been fixed in go 1.8, but since Docker is still using the bugged version, we might need to handle these ill-formed images created by Dcoker utilities.
NOTE: It is confirmed that the archive/tar package in go 1.8 cannot correctly extract the ill-formed tar files, but the one in go 1.7.5 could.
Details: the archive/tar package uses USTAR format to handle files with 100+-character-long paths (by only putting file name in the name field and the path in the prefix field in the tar header), but uses OLDGNU's magic string, which does not understand the prefix field, so a standard tar program will extract such files under the current directory.