Consecutive ENV in Dockerfile layer creation

I can’t find in Dockerfile reference | Docker Docs an explicit statement whether

ENV foo=1
ENV bar=2
ENV baz=3

Is equivalent to

ENV foo=1 \
  bar=2 \
  baz=3

In terms of number of layers created in the final image when doing docker buildx build . It would be nice if it was explicitly written out in that document one way or the other.

I also find the first style to be readable

I just tested it on v29.0.2: both don’t add layers.
I could only see a difference in docker history.

The same is true for LABEL.
The description for LABEL points out that using the 2nd syntax did decrease the image size for Docker <1.10.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.