Okay clearly I misunderstood something here. You’re accessing the Dockerfile ARG “foo” from $env:foo, instead of $foo. $env is Powershell, so how’d it get populated? Is that what ARG is actually doing: populating a Shell variable?
I just tried the same script using the default Windows shell and I was able to echo %foo%. I thought it was Docker performing the substitution. Rather, Docker just exposes the variable to the current shell.
Thank you for clearing this up!