3 ms·
Understood, sorry about that. But that's how it feels to me. It's mostly because my mental image of multistage builds is different, I see them as a way to mak
by imp0cat 2y ago
Understood, sorry about that.
But that's how it feels to me.
It's mostly because my mental image of multistage builds is different, I see them as a way to make the final image smaller by throwing away everything from the previous image.
So it does make sense to me that ARG values are thrown away after a new FROM instruction and if you need them, you need to declare them again.
These two guides have led me to this view, I blame the author! ;) They're excellent BTW, I've revisited them a lot.
https://vsupalov.com/docker-arg-env-variable-guide/#arg-and-env https://vsupalov.com/docker-arg-env-variable-guide/#arg-and-...
https://vsupalov.com/build-docker-image-clone-private-repo-ssh-key/ https://vsupalov.com/build-docker-image-clone-private-repo-s...
- MereInterest 2y ago> Understood, sorry about that. And apologies on my side, as I worded it a bit strongly. I agree with pretty much everything in your post, except for the implication that it would be magic. To me, the expected behavior is to follow lexical scoping, just like the vast majority of languages from the past several decades. > So it does make sense to me that ARG values are thrown away after a new FROM instruction and if you need them, you need to declare them again. True, and I'd expect an ARG from a previous stage to be undefined when in the next stage. Each ARG belongs to the scope in which it is declared, and a new scope is entered with each FROM statement. However, ARG statements prior to the first FROM statement don't fit into that model. They are before any FROM statement, so they can't belong to any FROM statement. There's a design decision on whether statements before the first FROM statement are a parent scope, or whether they are unrelated scopes, to the scope used for each stage. They feel like they should be a parent scope, because these ARG definitions can be used in a FROM statement, and so it keeps surprising me when they are instead treated as unrelated scopes.