gamechanger17
gamechanger17

Reputation: 4599

How to display/print a file while building a docker image

Folks, I am building a Docker image from a Dockerfile I am stuck on a silly position where I am updating a yaml file using sed.

RUN sed -i -e "s@\$REPLACEMENT_TAG@$PM_SERVER_DOCKER_TAG@" /qa.yaml

After this step I need to show the yaml file on the output console while building the docker image but I am not able to show it via echo command. Could someone help me with the correct syntax.

Upvotes: 5

Views: 32854

Answers (2)

John Kugelman
John Kugelman

Reputation: 361595

Use cat not echo. echo will print the name of a file. cat displays its contents.

RUN cat /qa.yaml

As per spankmaster79 in the comments, with the BuildKit backend you will also need --progress=plain for output. Thus, since you are supposedly debugging, you will need to do something similar to:

docker build --no-cache --progress=plain -t containername .

Upvotes: 22

Atish Kumbhar
Atish Kumbhar

Reputation: 635

+1 for 'cat' but, if you still want to use echo you can use as given below

RUN echo "$(<filename)"

Upvotes: 5

Related Questions