Comments (9)
Automatic extraction (with ADD
) only works for local archives; if you only need the files, not the archive, it's better to just add the extracted files, instead of a zip, and later extracting during docker build.
If you're adding a remote archive; use a multi stage build, and decompress in an intermediate build-stage
from buildkit.
I think this is a dupe of moby/moby#15036
As mentioned in that issue, ADD
id not recommend best practice so I'm not sure it's worth extending it.
from buildkit.
I'm not married to ADD as the keyword but the scenario is pretty valuable.
from buildkit.
@taylorb-microsoft the problem is that you typically don't want exactly what's in a .zip. Instead, you want the zip, do some transformation on the contents (eg. compile source code), and then get rid of anything from the zip you don't need. To keep image-size minimal, you want to do that in a single layer.
Here's an example: https://github.com/docker-library/golang/blob/master/1.8/windows/windowsservercore/Dockerfile#L15
Details here: https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#add-or-copy
Do you have a specific use-case in mind?
from buildkit.
ADD
has been frozen a few years ago. It's been discussed a bunch of times already on this issue tracker. The issue with ADD is that it has too much magic and it's pretty hard to keep track of all the edge cases when using the instruction in a Dockerfile.
ADD
shouldn't be extended at all. Instead, new keywords which state the action to be taken explicitly should be introduced. COPY
was the first instruction which was meant to help deprecate ADD
in favor of specialized instructions. This means we should split up ADD
into separate instructions. COPY
already copies files. UNPACK
or EXTRACT
should handle various archives (.tar.gz, .tar.bz2, .tar.xz, .zip). Another instruction should exist for the retrieval of files from remote sources. This fetch instruction could also have a parameter which allow the archive to be extracted or just retrieved for storage as it is.
from buildkit.
Thanks, we are looking at bringing better compression tools support into Windows but it does seem like being able to accomplish these operations without starting a container might be beneficial.
from buildkit.
@taylorb-microsoft Perhaps this is something to discuss to come up with a new instruction for the Dockerfile. It really is a bad idea to overload ADD
any further with any new functionality.
There's no reason why such functionality couldn't be added using a different new instruction (UNPACK
, EXTRACT
and so on). It's just that it needs a bit more effort to make sure we take into account all the various scenarios.
from buildkit.
But how do you integrate ZIP files then? AFAIK, the COPY instruction will create an image layer you do not need afterwards in most cases for this scenario.
This is a waste of space which will become noticable for large archives.
https://devops.stackexchange.com/questions/3172/copy-and-zip-files-in-dockerfile
from buildkit.
Automatic extraction (with
ADD
) only works for local archives; if you only need the files, not the archive, it's better to just add the extracted files, instead of a zip, and later extracting during docker build.
I need to be able to build under Windows and the NTFS filesystem mapping may not preserve the original metadata exactly, hence I would like to unpack an archive instead.
from buildkit.
Related Issues (20)
- [WCOW] GC storage limit is initialized with constant value
- Permissions issue when querying builder on Windows HOT 15
- WCOW can only use the local exporter if there are no nested directories in the layer HOT 1
- wcow: scope security descriptor for the npipe and make it configurable HOT 2
- Unable to copy file via hard link when using buildkit HOT 2
- Add support for using `ARG`s in `ENTRYPOINT` HOT 1
- S3 touch fails on files greater than 5GB in size HOT 4
- wishlist: annotations on docker/dockerfile images HOT 2
- WCOW fails to load custom frontend HOT 3
- Proposal: Use referrers api to import/export inline type cache
- bake does not merge compose services/<service>/build/x-bake setting with serivice extensions
- copy --parents silently ignores nonexistent paths HOT 2
- buildkit WCOW cannot seemingly run `RUN powershell ...`, while vanilla dockerd can HOT 4
- Proposal: csv syntax for git repos HOT 4
- Support extracting `ADD --checksum=.. https://.. ..` HOT 6
- 0.13.2 corrupts cache and cannot start (`go.etcd.io/bbolt.(*freelist).read`, `panic: invalid freelist page: 0, page type is unknown<0`) HOT 5
- Local and Registry cache not used or *invalidating* cache unnecessarily HOT 3
- can't add CA cert for gha remotecache?
- Inconsistencies in RUN mount options parsing/handling HOT 1
- dockerfile: Add integration test for ARG with empty value and default
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from buildkit.