【发布时间】:2018-06-13 12:42:57
【问题描述】:
我正在尝试在进行 docker 构建时提取我正在处理的存储库,所以我关注了this tutorial,所以我添加了我的Dockerfile
# this is our first build stage, it will not persist in the final image
FROM ubuntu as intermediate
# install git
RUN apt-get update \
apt-get upgrade \
apt-get install git
# add credentials on build
RUN mkdir ~/.ssh && ln -s /run/secrets/host_ssh_key ~/.ssh/id_rsa
# make sure your domain is accepted
RUN touch /root/.ssh/known_hosts
RUN ssh-keyscan github.org >> /root/.ssh/known_hosts
RUN git clone git@github.com:my-repo/myproject.git
FROM ubuntu
# copy the repository form the previous image
COPY --from=intermediate /your-repo /srv/your-repo
在我的docker-compose.yml 中添加了
secrets:
host_ssh_key:
file: ~/.ssh/id_rsa
我正在添加
secrets:
- host_ssh_key
在其中一项服务中。
由于这仅供我本地使用(我不打算部署或将其用于生产,我只是想测试一下)以这种方式使用它很好 - 如果它可以工作,因为目前在 git install 阶段构建失败并出现错误
E:更新命令不带参数
错误:服务“web”构建失败:命令“/bin/sh -c apt-get update apt-get upgrade apt-get install git”返回非零代码:100
我错过了什么?
【问题讨论】:
-
你能接受答案吗?以便向其他人表明某些解决方案对您有帮助。如果你对所有有答案的问题都做了,那就太好了。
-
当然,尽管最后我做了不同的事情。感谢您的帮助:)