ARG in WORKDIR not applied

It is explained in the same documentation I linked in my previous post.

Prior to its definition by an ARG instruction, any use of a variable results in an empty string.

In other words, it works like variables in a shell, so unset variables will be used as empty string. You can use this syntax to avoid it:

WORKDIR /home/${TOPIC:?}

Or add a custom error message:

WORKDIR /home/${TOPIC:?Do not leave it empty}
1 Like