Docker RUN失败,并返回非零代码:6“ [英] Docker RUN fails with "returned a non-zero code: 6"

查看:1342
本文介绍了Docker RUN失败,并返回非零代码:6“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Docker文件中有以下内容:

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

但是当我尝试使用以下方式构建我的映像失败:

 捕获异常:命令'/ bin / sh -c sshpass -p userPassword scp -r user @ server:〜/ data / * ./'返回一个非零代码:6  - > [帮助1] 

但是,如果我删除这些行,将图像,ssh构建到容器上,手动运行命令从bash它的工作完美。



有谁可以告诉我如何解决这个问题?

解决方案

退出代码 6 表示主机公钥未知。 sshpass退出而不确认新密钥。



所以你先填写〜/ .ssh / known_hosts 之前,使用主机的指纹,或者忽略检查主机公钥通过向scp添加 StrictHostKeyChecking = no 选项。



更新的行将如下所示:

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


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?

解决方案

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/* ./

这篇关于Docker RUN失败,并返回非零代码:6“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆