"Empty continuation lines will become errors" ... how do I now comment on a Docker file?

Consider the following Docker file:

FROM alpine:edge EXPOSE \ # web portal 8080 \ # backdoor 8081 

Built like this:

 docker build . 

We observe the following conclusion:

 Sending build context to Docker daemon 17.1TB Step 1/2 : FROM alpine:edge ---> 7463224280b0 Step 2/2 : EXPOSE 8080 8081 ---> Using cache ---> 7953f8df04d9 [WARNING]: Empty continuation line found in: EXPOSE 8080 8081 [WARNING]: Empty continuation lines will become errors in a future release. Successfully built 7953f8df04d9 

So, given that it will soon become illegal to post comments in the middle of a multi-line section: what is the new recommended way to comment multi-line commands ?

This is especially important for RUN commands, as we are advised to reduce image levels with the && commands.


Not sure when it was introduced, but I'm currently testing this in version:

 🍔 docker --version Docker version 17.07.0-ce, build 8784753 

I use the release stream on docker, so maybe this still doesn't look familiar if you use the Docker stabilizer.

+8
docker dockerfile
source share
2 answers

07.17.0-ce began to warn of empty continuation lines. However, it only incorrectly treated comment lines as empty. This is fixed in moby # 35004 and is included in 10/17/08 .

+5
source share

You can split the RUN commands into separate lines and then use the experimental (while writing *) --squash .


* note that it has been suggested that multi-stage builds may make --squash redundant. This is actively discussed here here , with the open clause here .

+1
source share

All Articles