docker - 在 Dockerfile 中找不到 ssh-keyscan

标签 docker

我有一个简单的 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 belowpjotr-dolphin :

If you are only after ssh-keyscan, openssh-client has smaller footprint than ssh package.

其实,package openssh-clients for RedHat/CentOS ,如 commentedOleg Neumyvakin

关于docker - 在 Dockerfile 中找不到 ssh-keyscan,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32665746/

相关文章:

docker - 由于 'unauthorized access'错误,无法将Docker Image推送到Heroku存储库

docker - 'LibreSSL SSL_connect : SSL_ERROR_SYSCALL' on curl to NGINX reverse proxy on a Docker Container

python - Docker 映射外部配置文件

docker - Gitlab CI 作业随机失败/通过

linux - 检查权限的脚本

ruby-on-rails - Rails docker应用程序捆绑 rake 被中止

docker - 如何使用 docker compose v3 在容器中直接挂载 NFS 共享/卷

Dockerfile 复制与 "docker run ... cp"

基于 Docker、CoreOS 和队列的部署

docker - 如何在同一个docker容器或dyno中运行2个进程?