我有一个简单的 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
服务器上进行本地测试。
作为 commented below由 pjotr-dolphin :
If you are only after
ssh-keyscan
,openssh-client
has smaller footprint than ssh package.
其实,package openssh-clients
for RedHat/CentOS ,如 commented由 Oleg Neumyvakin
关于docker - 在 Dockerfile 中找不到 ssh-keyscan,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32665746/