我正在尝试在进行 docker 构建时提取我正在处理的存储库,所以我按照 本教程 进行操作,所以我添加了我的 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
我错过了什么?
原文由 dingo_d 发布,翻译遵循 CC BY-SA 4.0 许可协议
你过度分析了这一点。这只是一个简单的错字。应该:
这些是 3 个单独的命令。