In places where key-value pairs are used, a space before the equal sign may lead to unintended behavior.
A few Docker instructions (like ARG, ENV, LABEL) may contain key-value pairs in form of
<key>=<value>. The equal sign should not be followed by a space. The space before the equal sign may lead to unintended
behavior. This is critical, especially for multiple key-value pairs, e.g. key1 = value1 key2 = value2, will lead to the key
key1 with the value = value1 key2 = value2. In most cases it is unintended.
ENV BUILD_NUMBER =1 RUN echo $BUILD_NUMBER
This will lead to print =1, which is not expected.
ENV BUILD_NUMBER=1 RUN echo $BUILD_NUMBER
This will lead to print 1, which is expected.
ENV USER = bob MODE = all RUN echo $USER
This will lead to print = bob MODE = all, which is not expected.
ENV USER=bob MODE=all RUN echo $USER
This will lead to print bob, which is expected.
The ENV instruction allows alternative syntax ENV <key> <value> and in case of space before equal sign, the
=1 is evaluated as value. The LABEL instruction will be also evaluated to =1. The ARG instruction
will cause the build error.