git - Dockerfile 中的 git install 失败
问题描述
我正在尝试在进行 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
我错过了什么?
解决方案
你过度分析了这一点。这只是一个简单的错字。应该:
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y git
这些是 3 个单独的命令。
推荐阅读
- scala - 在 spark sq 中收集以获取值的列表或映射的替代方法
- html - 如何为导航菜单中的两个元素设置活动背景颜色
- python-3.x - 将 Pandas 日期舍入到最近的年/月
- graph - 如何从 DSE 模式中删除两个顶点之间的边
- java - 使用 JpaRepository 从数据库中更新和删除
- shell - 使用 wget 下载 url 列表中的文件
- ios - 如何修复 xcode 中冲突的配置设置?
- foreach - 每个活动的 Azure 数据工厂管道不按顺序工作
- java - 编译时没有 Ljava/nio/charset/Charset 类型的静态字段 DEF_CONTENT_CHARSET;在 Lorg/apache/http/protocol/HTTP 类中;
- augmented-reality - 在 A-Frame (AR.js) 中,想要使 3D 对象看起来从地板上出来,即以某种方式在标记下方剪辑/蒙版