6 ms·
wait, do you mean adding another layer for npm installing other deps?
by orliesaurus 8y ago
wait, do you mean adding another layer for npm installing other deps?
- jopsen 8y agoNo, doing npm install in a different container and copying over the result. Docker has multi-stage build, which allows using a container to build and copying over in a different result container.. I suspect this could be relevant many place, keeping images small also hardens security.
- orliesaurus 8y agoOh, what are the advantages of doing that in a different container as opposed to a different layer? Trying to understand the pros/cons.. Isn't it faster to add extra layers, than extra containers?
- wolfgang42 8y agoDifferent layer means you have to carry around that layer in your final image. If you do a multi-stage build, you can copy over just the bits you need into the final image.
- vsviridov 8y agoLayers are add only. If you removea file, it still exists in the parent layer, propagating bloat
- heroic 8y agoThis is the builder pattern in docker. You do things in one "throw away" container, use results from this container and copy them into another. The final container gets only one layer now, instead of maybe 10s that your "throw away" container had.