Skip to content

Error preparing context folder under Windows #890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lreimer opened this issue Aug 7, 2017 · 6 comments
Closed

Error preparing context folder under Windows #890

lreimer opened this issue Aug 7, 2017 · 6 comments

Comments

@lreimer
Copy link

lreimer commented Aug 7, 2017

This issue relates to the following bmuschko/gradle-docker-plugin#432

The Docker Gradle plugin is using the docker-java library in version 3.0.12. When using the plugin in a Gradle build under Windows the following exception occurs (only snippet):

        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:95)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:76)
        ... 70 more
Caused by: java.io.IOException: Der Prozess kann nicht auf die Datei zugreifen, da ein anderer Prozess einen Teil der Datei gesperrt hat
        at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:2146)
        at org.apache.commons.io.IOUtils.copy(IOUtils.java:2102)
        at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:2123)
        at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:1107)
        at com.github.dockerjava.core.util.CompressArchiveUtil.archiveTARFiles(CompressArchiveUtil.java:105)
        at com.github.dockerjava.core.dockerfile.Dockerfile$ScannedResult.buildDockerFolderTar(Dockerfile.java:135)
        ... 92 more
        Suppressed: java.io.IOException: This archives contains unclosed entries.
                at org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.finish(TarArchiveOutputStream.java:225)
                at org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.close(TarArchiveOutputStream.java:241)
                at com.github.dockerjava.core.util.CompressArchiveUtil.archiveTARFiles(CompressArchiveUtil.java:109)
                at com.github.dockerjava.core.dockerfile.Dockerfile$ScannedResult.buildDockerFolderTar(Dockerfile.java:135)

The IOException tells me that someone has locked a file the library wants to use and include in the context TAR file. But this bug only happens under Windows, when I run the exact same build on my Mac everything is OK.

Any ideas how to analyse / fix this? If you need a project to reproduce the behaviour, you can use https://github.com/lreimer/everything-as-code

@orzeh
Copy link
Contributor

orzeh commented Aug 7, 2017

@lreimer I don't think this is a bug. To build image you have to send build context to docker daemon. In your case one of files is locked (partially) and can't be read. How would you fix that? The only solution is to release the lock.

@lreimer
Copy link
Author

lreimer commented Aug 7, 2017

But why is it working OK under MacOS and only complaining under Windows? Is there maybe some kind of flag one could give to the Apache Commons TarArchiveOutputStream.finish() method?

@orzeh
Copy link
Contributor

orzeh commented Aug 7, 2017

@lreimer because only on Windows some other process locks that file. The solution with flag is tricky, why we should silently remove locked files from build context? What if they are required to build an image?

@gesellix
Copy link
Contributor

gesellix commented Aug 7, 2017

If I recall correctly, I also had similar issues and it seemed like the Gradle process itself (via daemon?) holds a lock on those files. My workaround was to copy the build context to another directory.

@orzeh
Copy link
Contributor

orzeh commented Aug 7, 2017

My workaround was to copy the build context to another directory

Or just create .dockerignore excluding .gradle dir and other not needed stuff. Build will be faster!

@lreimer
Copy link
Author

lreimer commented Aug 7, 2017

Thanks for all your comments.

I already have a .dockerignore file. The file I want to add via COPY is a .tar file produced by the application plugin in the Gradle build/ directory.

So I will try to narrow down the build/ directory even further using .dockerignore. Maybe that helps. Otherwise I will try to copy the file somewhere else and use it from there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants