Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Empty continuation lines will become errors"… how should I comment my Dockerfile now?

Consider the following Dockerfile:

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

Built like so:

docker build . 

We observe such output:

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'll soon become illegal to put comments in the middle of a multi-line section: what's the new recommended way to comment multi-line commands?

This is particularly important for RUN commands, since we are encouraged to reduce image layers by &&ing commands together.


Not sure exactly when this was introduced, but I'm currently experiencing this in version:

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

I'm using Docker's edge release stream, so maybe this will not yet look familiar if you are using Docker stable.

like image 246
Birchlabs Avatar asked Oct 12 '17 11:10

Birchlabs


2 Answers

17.07.0-ce started to warn on empty continuation lines. However, it incorrectly treated comment-only lines as empty. This is fixed in moby#35004, and being included in the 17.10.0-ce.

like image 192
Tanner Sansbury Avatar answered Sep 19 '22 07:09

Tanner Sansbury


On top of what others have said above (the error might be related to comments inside continuation blocks and/or windows cr/lf characters = use dos2unix), this message can also show up when your last command ends with a backslash \ character. For example, if you have this:

RUN apt-get update \     && apt-get upgrade \     && apt-get -y install build-essential curl gnupg libfontconfig ca-certificates bzip2 \     && curl -sL https://deb.nodesource.com/setup_16.x  | bash - \     && apt-get -y install nodejs \     && apt-get clean \     && rm -rf /tmp/* /var/lib/apt/lists/* \ 

Notice the last \ at the end. This will get you the same error:

docker [WARNING]: Empty continuation line found in:

So, just remove that last \ and you're all set.

like image 32
Pierre Avatar answered Sep 22 '22 07:09

Pierre