【发布时间】:2017-11-02 05:09:40
【问题描述】:
在我的 Dockefile 中,我正在向 docker 添加 ssh 密钥并从 bitbucket 克隆一个项目。 我可以轻松地在 Docker 文件中拉出另一个分支。
ARG key
ARG pub_key
RUN mkdir /root/.ssh/
RUN ssh-keyscan bitbucket.org >> /root/.ssh/known_hosts
ADD $key /root/.ssh/
ADD $pub_key /root/.ssh/
RUN git clone git@bitbucket.org:******************/sql.git
WORKDIR "/sql"
RUN git pull origin testBranch
repo 被成功克隆,并且从 testBranch 成功拉取
当我使用docker run 命令运行这个 docker 并尝试它说的任何 git 命令时
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
但 ssh 密钥存在于目录/root/.ssh
【问题讨论】: