Suppress or hide Docker "Steps" and default output in the console

Viewed 1106

I have a Dockerfile where I would like to customize the output console.

Simplified example:

FROM node:Alpine

RUN echo 'Starting container build'
RUN echo 'Copying files...'

WORKDIR /that
COPY ./this /that

RUN echo 'Copy complete. Directory contents:'
RUN ls

I would like an output like so:

Starting container build
Copying files...
Copy complete. Directory contents:
file1.ts
file2.ts
file3.ts
...

However, Docker adds these "Step x/x : " and "Running in 314159265359" messages, giving a messy output

Actual output:

Step 1/7 : FROM node:Alpine
 ---> 314159265359
Step 2/7 : RUN echo 'Starting container build'
 ---> Running in 314159265359
Starting container build
Removing intermediate container 314159265359
 ---> 314159265359
Step 3/7 : RUN echo 'Copying files...'
 ---> Running in 314159265359
Copying files...
Removing intermediate container 314159265359
 ---> 725d85e0131c
Step 4/7 : WORKDIR /that
 ---> Running in 314159265359
Removing intermediate container 314159265359
 ---> 314159265359
Step 5/7 : COPY ./this /that
 ---> 314159265359
Step 6/7 : RUN echo 'Copy complete. Directory contents:'
 ---> Running in 314159265359
Copy complete. Directory contents:
Removing intermediate container 314159265359
 ---> 314159265359
Step 7/7 : RUN ls
 ---> Running in 314159265359
file1.ts
file2.ts
file3.ts
...

Any ideas on how I could achieve a custom output? Not a huge issue but vanity is important :-)

*I know there are options to simply hide all output but I just want to only hide the built-in messages.

** Additionally, I'm using docker-compose, in case there's some magic option there as well

1 Answers

Any ideas on how I could achieve a custom output?

You can post-process any command output.

docker build ... | sed '/^Step/d; /^Running/d'
Related