【问题标题】:Dockerfile can't find my private ssh keyDockerfile 找不到我的私有 ssh 密钥
【发布时间】:2014-02-25 16:36:12
【问题描述】:

我正在尝试构建一个 dockerfile,以便它克隆一个私有 repo。我相信我已经添加了正确的代码来执行此操作,但它一直抛出此错误:

build: id_rsa: no such file or directory

我已确保路径正确且密钥在其中,并尝试了此处提出的许多其他解决方案,例如取消注释 ssh_config 中的 IdentityFile 无济于事。这是我的 dockerfile:

FROM ubuntu:latest
MAINTAINER John Fink <john.fink@gmail.com>
RUN apt-get update # Thu Nov  7 22:40:44 EST 2013


RUN apt-get install -y mysql-client mysql-server apache2 libapache2-mod-php5 pwgen      python-setuptools vim-tiny php5-mysql git

RUN easy_install supervisor

ADD id_rsa /root/.ssh/id_rsa
ADD known_hosts /root/.ssh/known_hosts
RUN echo " IdentityFile /root/.ssh/id_rsa" >> /etc/ssh/ssh_config

RUN cd /var/www
RUN git clone git@dev.ploonky.com:eric/hartshorn-portraiture.git

ADD ./start.sh /start.sh
ADD ./foreground.sh /etc/apache2/foreground.sh
ADD ./supervisord.conf /etc/supervisord.conf
RUN chmod 755 /start.sh
RUN chmod 755 /etc/apache2/foreground.sh
EXPOSE 80
CMD ["/bin/bash", "/start.sh"]

【问题讨论】:

  • 你知道/root/.ssh目录存在于ADD id_rsa /root/.ssh/id_rsa这一行之前吗?

标签: apache ssh docker


【解决方案1】:

您的id_rsa 文件是否在您的 Dockerfile 所在的当前目录中?尝试指定它的完整路径

【讨论】:

  • 我真是个白痴,我以为“root”指的是我计算机的根目录,而不是 Dockerfile 的。谢谢
【解决方案2】:

我做了一个更暴力的版本来看看,并且

FROM ubuntu
RUN apt-get -yq install ssh
ADD .ssh /root/.ssh/
CMD     bash

失败 -

sven@mini:~/src/docker/tmp$ docker run -rm -t -i test 
root@810a2b43ed12:/# ls -la /root
total 20
drwx------  3 root root 4096 Feb 20 04:12 .
drwxr-xr-x 45 root root 4096 Feb 20 04:17 ..
-rw-r--r--  1 root root 3106 Apr 19  2012 .bashrc
-rw-r--r--  1 root root  140 Apr 19  2012 .profile
drwx------  2 1000 1000 4096 Feb 20 04:04 .ssh
root@810a2b43ed12:/# ssh sven@192.168.1.220
Bad owner or permissions on /root/.ssh/config
root@810a2b43ed12:/# chown -R root:root /root/.ssh/
root@810a2b43ed12:/# ssh sven@192.168.1.220
Linux mini 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64

所以我想说你只需要做一个

RUN chown -R root:root /root/.ssh

你应该很高兴。

【讨论】:

    猜你喜欢
    • 2020-03-29
    • 2020-12-27
    • 1970-01-01
    • 1970-01-01
    • 2020-01-17
    • 2012-12-29
    • 1970-01-01
    • 2017-08-18
    • 1970-01-01
    相关资源
    最近更新 更多