How can I suppress the output of the RUN command in a Dockerfile? In the code below, I’m attempting to redirect the SSH_PRIVATE_KEY to a file using the echo command. However, during image building, the Docker logs reveal the SSH PRIVATE KEY, which I’d like to avoid. Is there a way to silence the RUN command in a Dockerfile, or is there another solution to this issue?
RUN echo "${SSH_PRIVATE_KEY}" > /home/$USER/.ssh/id_ed25519
Build log
=> CACHED [app 10/19] RUN echo "-----BEGIN OPENSSH PRIVATE KEY-----0s9 0.0s
2
Answers
You can redirect both standard output and standard error to
/dev/null
, such as:A simple workaround is to have the key in a file instead in the first place.
with
privkey
obviously in a local file in the directory where you rundocker build
et al.