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
Dockerfile ADD should support ZIP archives as well #15036
Comments
|
It was decided back in 2014 that the ADD instruction would be frozen and it would not get extended any further. Fortunately, https://github.com/jlhawn/dockramp has been created and the builder will be moved away from the daemon. This means it'll be possible to extend it further. I'm going to close this issue now because doing this should be possible once dockramp arrives. |
|
Is there any way to copy a zip file into an image, and unzip it without storing the intermediate zip file in a layer? Still stores the zip file in the intermediate layer. |
|
Wondering, if these are local files, is there a reason to have them as You could use multi-stage builds, e.g.; FROM builderimage AS build-stage
COPY src.zip file.zip
RUN unzip file.zip
RUN build your binaries from the src
FROM deploybase
COPY --from build-stage /build-output/ /usr/bin/ |
|
Thanks for the reply. They are java WAR files which are built outside of Docker. It's actually more complex than my original question because they are also copied in using an ONBUILD instruction from the parent Dockerfile. I can unzip them in the image startup script instead but it takes a few sec, so I was just trying to unzip them in advance (at the expense of a small increase in image size). The ADD command seems to be deprecated, but AFAICT there isn't really anything that replaces it for local files? If they were remote files, Maybe an equivalent way of chaining Dockerfiles e.g. |
|
The @thaJeztah reply is great. Just make sure you use
rather than the example above. The argument to |
|
Windows does not come with a builtin unzip tool as far as I know, so it is rather tedious to work around the lack of zip support here. There's no easy "unzip xx.zip". Or is there? |
|
It’s not installed by default on Linux as well, but that’s were intermediate stages are used for; you can install tools that are needed for that step (eg to extract and compile your code) |
|
“on linux” here in the context of Docker images (which are kept minimal) |
|
@sandersaares Powershell V5 supports Expand-Archive, that extract zip files as well, as reported in https://docs.microsoft.com/it-it/powershell/module/Microsoft.PowerShell.Archive/Expand-Archive . Before, you need to use a vbscript |
(disclaimer: I don't exclude the possibility there's a valid reason why this isn't supported OOTB... Slam me down if there is.)
At the moment, the Dockerfile reference for ADD reads:
It's a bit surprising that zip support isn't available, especially as a lot of software components are often available only as zip archives (for better or worse).
I have a few in-house projects building upon docker that rely on packages released by some other teams as ZIP archives. And as a result of this, I always need to pre-convert from .zip to .tar.gz or .tar so I get can benefit from ADD's auto-uncompress feature.
Yes, I know, sounds like a very insignificant gripe. I could uncompress myself, remove layers, etc... but I always thought ADD's semantic worked nicely and elegantly in that case, even if putting aside the debate about having the same feature for remote . So at the moment my approach is to script the conversion beforehand.
However, I always wondered why ADD doesn't support that out of the box for ZIPs. I haven't dived - yet - into the implementation, but my guess was simply library support and the ZIP structure not being friendly for streaming?
In any case, that'd be a nice - if ever so small - feature to add.
Hopefully, I'll have time to look into it for myself.
The text was updated successfully, but these errors were encountered: