Docker RUN fails with "returns non-zero code: 6"

My docker file has the following:

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

But when I try to create my image, it fails:

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 delete these lines, create an image, ssh on the container and manually run the command from bash, it works fine.

Can someone tell me how to get around this?

+4
source share
1 answer

Exit code 6 means that " the host public key is unknown. Sshpass exits without confirming the new key.

, , ~/.ssh/known_hosts , , StrictHostKeyChecking=no scp.

:

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

Source: https://habr.com/ru/post/1617766/


All Articles