Dockerfile "RUN |5" semantic

Hello,

Reading Dockerfile image layers on Docker Hub I came across a syntextic artefact I did not find any explanation about in the nineth layer, at the level of the run instruction:

RUN |5

RUN is followed by a |5. What does mean this notation ? Is it documented somewhere ?
Thank you for your contribution,

Alain

|5 must be the number of arguments that RUN instruction is using. Iā€™m not sure why that is necessary there, but you can try this Dockerfile to confirm it:

FROM ubuntu:22.04

ARG A=1
ARG B=2

RUN echo "HELLO"
docker build . -t localhost/test
docker image history localhost/test
IMAGE          CREATED         CREATED BY                                      SIZE      COMMENT
2464cec638cf   5 seconds ago   RUN |2 A=1 B=2 /bin/sh -c echo "HELLO" # buiā€¦   0B        buildkit.dockerfile.v0
<missing>      5 seconds ago   ARG B=2                                         0B        buildkit.dockerfile.v0
<missing>      5 seconds ago   ARG A=1                                         0B        buildkit.dockerfile.v0
<missing>      2 months ago    /bin/sh -c #(nop)  CMD ["/bin/bash"]            0B
<missing>      2 months ago    /bin/sh -c #(nop) ADD file:1043594b482384e96ā€¦   69.2MB
<missing>      2 months ago    /bin/sh -c #(nop)  LABEL org.opencontainers.ā€¦   0B
<missing>      2 months ago    /bin/sh -c #(nop)  LABEL org.opencontainers.ā€¦   0B
<missing>      2 months ago    /bin/sh -c #(nop)  ARG LAUNCHPAD_BUILD_ARCH     0B
<missing>      2 months ago    /bin/sh -c #(nop)  ARG RELEASE                  0B

In this example you will see |2 because I had two build arguments. It is probably just a metadata to show Docker what part of the line is env variables and what is the rest of the command.

update:

I should have mentioned that it is not something you need to or can use in a Dockerfile. It is just what you see in the history.

2 Likes

Thank you Ɓkos