我有一个简单的Dockerfile,如下所示:
FROM ubuntu:14.04
RUN apt-get update
RUN apt-get -y upgrade
RUN mkdir -p /root/.ssh
RUN touch /root/.ssh/known_hosts
RUN ssh-keyscan github.com >> /root/.ssh/known_hosts
运行结果:
docker build -no-cache -t testimage .
是:
Step 5 : RUN ssh-keyscan github.com >> /root/.ssh/known_hosts
---> Running in e11ef5962a11
/bin/sh: 1: ssh-keyscan: not found
最佳答案
您需要先安装ssh.
RUN apt-get -yq update && \
apt-get -yqq install ssh
然后,各种ssh命令,包括ssh-keyscan,都可用.
这就是我在sshd
image Dockerfile中所做的.
我用它到add localhost
to my .ssh/known_hosts
,以便在sshd服务器上进行本地测试.
截至pjotr-dolphin pjotr-dolphin:
If you are only after
ssh-keyscan
,07004 has smaller footprint than ssh package.
实际上,package openssh-clients
for RedHat/CentOS,Oleg Neumyvakin Oleg Neumyvakin