"Host key verification failed" when deploying Dockerfile app in RHOCP 4
Issue
- When attempting to deploy a
Spring Boot
application using a Dockerfile, encountered an error, Host key verification failed, while trying to clone the code using the provided SSH files in the Dockerfile. - The used Dockerfile used:
// Installing git
FROM image-registry.openshift-image-registry.svc:5000/openshift-xxx-streams/xyz
// Add ssh private key into the container
RUN mkdir ~/.ssh/
COPY ./id_rsa ~/.ssh/
RUN echo -e "StrictHostKeyChecking no" >> ~/.ssh/id_rsa
RUN chmod 600 ~/.ssh/id_rsa
// clone the container
RUN git clone ssh://git@bitbucket.xxx.xx.x:7999/xxx/xyz.git && git clone ssh://git@bitbucket.xxx.xx.x:7999/xxx/xyz.git
While executing the above Dockerfile
, getting the error below:
"Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists."
Environment
- Red Hat OpenShift Container Platform (RHOCP) 4
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.