Skip to content
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

Closed
laurent-malvert opened this issue Jul 27, 2015 · 9 comments
Closed

Dockerfile ADD should support ZIP archives as well #15036

laurent-malvert opened this issue Jul 27, 2015 · 9 comments
Labels
kind/enhancement Enhancements are not bugs or new features but can improve usability or performance.

Comments

@laurent-malvert
Copy link

(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:

If is a local tar archive in a recognized compression format (identity, gzip, bzip2 or xz) then it is unpacked as a directory. Resources from remote URLs are not decompressed. [...]

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.

@thaJeztah thaJeztah added kind/proposal kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. labels Jul 27, 2015
@unclejack
Copy link
Contributor

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.

@markvr
Copy link

markvr commented Aug 14, 2017

Is there any way to copy a zip file into an image, and unzip it without storing the intermediate zip file in a layer?
Using:

COPY src.zip file.zip
RUN unzip file.zip && rm file.zip

Still stores the zip file in the intermediate layer.

@thaJeztah
Copy link
Member

Wondering, if these are local files, is there a reason to have them as .zip in the first place?

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/

@markvr
Copy link

markvr commented Aug 14, 2017

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, RUN curl....&& unzip... would do the job without creating an intermediate layer.

Maybe an equivalent way of chaining Dockerfiles e.g. COPY ... && RUN... would be useful...?

@netwolfuk
Copy link

The @thaJeztah reply is great. Just make sure you use

COPY --from=build-stage

rather than the example above. The argument to --from uses = as the assignment.

@sandersaares
Copy link

sandersaares commented Feb 9, 2018

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?

@thaJeztah
Copy link
Member

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)

@thaJeztah
Copy link
Member

“on linux” here in the context of Docker images (which are kept minimal)

@henryx
Copy link

henryx commented Sep 10, 2018

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Enhancements are not bugs or new features but can improve usability or performance.
Projects
None yet
Development

No branches or pull requests

7 participants