我正在尝试拉出我正在进行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
Run Code Online (Sandbox Code Playgroud)
在我的docker-compose.yml我加
secrets:
host_ssh_key:
file: ~/.ssh/id_rsa
Run Code Online (Sandbox Code Playgroud)
我正在补充
secrets:
- host_ssh_key
Run Code Online (Sandbox Code Playgroud)
在其中一项服务.
由于这仅供我本地使用(我不打算在生产中部署或使用它,我只想测试它)这样使用它是好的 - 如果它能够工作,因为目前构建失败了git安装阶段有错误
E:update命令不带参数
错误:服务'web'无法构建:命令'/ bin/sh -c apt-get update apt-get upgrade apt-get install git'返回非零代码:100
我错过了什么?
Ale*_*hin 27
你是在分析这个.这只是一个简单的错字.应该:
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y git
Run Code Online (Sandbox Code Playgroud)
这是3个单独的命令.
一些想法:
apt-get install git为apt-get install --assume-yes git。没有--assume-yes它,它将提示您进行确认,您将无法给出确认,并且它很聪明,可以弄清楚这一点并假设您的意思是“否”。0600。我只复制它,并且特别chmod 0600 ~/.ssh/id_rsa确定。总体而言,您的Dockerfile看起来非常聪明,阅读它后我得到了一些新的想法。
| 归档时间: |
|
| 查看次数: |
22866 次 |
| 最近记录: |