question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Build command fails when symlinks in docker folder are used

See original GitHub issue

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);
        }
    }

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
hugarescommented, Jul 9, 2019

Ok, the pull request https://github.com/docker-java/docker-java/pull/1211 fixed the unit tests as mentioned before and I also added the many tests to increase coverage to cover the tar created and passed to the docker daemon. I will work on fixing the issue now.

0reactions
hugarescommented, Jul 8, 2019

The pull request is related to this bug because I fixed the units tests that now fails because symlink are not preserved. The only thing is the unit tests are testing CompressArchiveUtil.tar method which is not the method used when sending the docker build folder to docker daemon.

I will either add tests for CompressArchiveUtil.archiveTARFiles or rework both methods to remove the code duplication and then I will fix code to preserve symlinks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Docker does not follow symlinks within build directory
The Options as I see them: Create a bash/sh script to copy the files into public after both repositories are setup.
Read more >
Access denied when creating symlinks in docker-windows ...
I am running into access denied problems when creating symbolic links with windows-docker runners. The problem seems to be only happen when ...
Read more >
Error when running docker build on any dockerfile: "unable to ...
Dockerfile', it throws the error "unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /home/xxx/yyy/Dockerfile: no ...
Read more >
Docker Desktop release notes
A failed spawned command when building an extension no longer causes Docker Desktop to unexpectedly quit. Fixed a bug that caused extensions to...
Read more >
too many links in /var/lib/docker error while building Docker ...
The error "too many links" usually means that there is a symbolic link pointing to itself, and is not specific to docker. To...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found