The behavior of ARG in multi-stage Dockerfiles is a bit unusual. They are scoped to each stage, so you have to repeat them if you want to use the same variable in multiple stages. But, if you set a default value, that default value has to be set before the first stage. Ref. StackOverflow answer.
The container does not actually build without this change, because the ${CLANG_VERSION} variable expands to the empty string in the second stage, and then it fails installing clang--dev.
The behavior of ARG in multi-stage Dockerfiles is a bit unusual. They are scoped to each stage, so you have to repeat them if you want to use the same variable in multiple stages. But, if you set a default value, that default value has to be set before the first stage. Ref. StackOverflow answer.
The container does not actually build without this change, because the
${CLANG_VERSION}
variable expands to the empty string in the second stage, and then it fails installingclang--dev
.