Issue
I need to use SSH keys inside a container during build stage and I do that with
RUN echo "${SSH_KEY}" > /root/.ssh/id_rsa
Where SSH_KEY is build arg. The problem is, once this command is done, the output is messed up:
=> [internal] load build definition from Dockerfile 0.0s
[+] Building 733.0s (21/22)
=> [internal] load build definition from Dockerfile 0.0s
[+] Building 733.2s (21/22)
=> [internal] load build definition from Dockerfile 0.0s
[+] Building 733.3s (21/22)
=> [internal] load build definition from Dockerfile 0.0s
[+] Building 733.5s (21/22)
=> [internal] load build definition from Dockerfile 0.0s
[+] Building 733.6s (21/22)
=> [internal] load build definition from Dockerfile 0.0s
[+] Building 733.6s (22/22) FINISHED
Above is printed repeatedly until the build is done. Is there anything I can do about that?
Otherwise, the container building works fine.
Solution
As commenters suggested, using --mount=type=ssh
flag for RUN git clone
lines works a lot better.
Answered By - q30a Answer Checked By - Katrina (WPSolving Volunteer)