Why not just copy over the ssh keys into the docker container?
RUN mkdir -p /root/.ssh
COPY id_rsa /root/.ssh/id_rsa
COPY id_rsa.pub /root/.ssh/id_rsa.pub
RUN chmod 600 /root/.ssh/id_rsa && chmod 644 /root/.ssh/id_rsa.pub
RUN ssh-keyscan -H myrepo.com >> /root/.ssh/known_hosts