My Docker image includes some files, which are symlinks pointing outside of docker folder, e.g.
$ ls -l include/
total 0
lrwxrwxrwx 1 dmitry dmitry 29 Mar 30 17:25 python3.5m -> /usr/local/include/python3.5m
Native docker client handles this correctly. Java File.getCanonicalFile() follows symlinks, so TAR archive sent to Docker daemon contains usr/local/include/python3.5m/** instead of expected include/python3.5m/**, and as a result I get confusing errors about non-existent files.
I guess replacing FilePathUtil.relativize(File, File) with the following code would work, but please check if this behavior does not break other usages.
public static String relativize(File baseDir, File file) {
try {
return baseDir.toPath()
.toRealPath(LinkOption.NOFOLLOW_LINKS)
.relativize(file.toPath().toRealPath(LinkOption.NOFOLLOW_LINKS))
.toString();
} catch (IOException e) {
throw new DockerClientException(e.getMessage(), e);
}
}
My Docker image includes some files, which are symlinks pointing outside of docker folder, e.g.
Native docker client handles this correctly. Java
File.getCanonicalFile()follows symlinks, so TAR archive sent to Docker daemon containsusr/local/include/python3.5m/**instead of expectedinclude/python3.5m/**, and as a result I get confusing errors about non-existent files.I guess replacing
FilePathUtil.relativize(File, File)with the following code would work, but please check if this behavior does not break other usages.