Docker RUN fails with “returned a non-zero code: 6”

允我心安 提交于 2019-12-10 13:47:43

问题


I have the following in my docker file:

RUN sudo apt-get install sshpass -y
RUN sshpass -p userPassword scp -r user@server:~/data/* ./

But when I try and build my image it fails with:

Exception caught: The command '/bin/sh -c sshpass -p userPassword scp -r user@server:~/data/* ./' returned a non-zero code: 6 -> [Help 1]

However, if I remove these lines, build the image, ssh onto the container and manually run the command from bash it works perfectly.

Can anyone tell me how to get around this?


回答1:


The exit code 6 means that "Host public key is unknown. sshpass exits without confirming the new key."

So either you populate before that the ~/.ssh/known_hostswith the fingerprint of the host, or just ignore the check of the host public key by adding the StrictHostKeyChecking=no option to the scp.

The updated line would look like that:

RUN sshpass -p userPassword scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -r user@server:~/data/* ./


来源:https://stackoverflow.com/questions/33961214/docker-run-fails-with-returned-a-non-zero-code-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!