【问题标题】:Dockerfile build fails with source-command not foundDockerfile 构建失败,找不到源命令
【发布时间】:2022-01-24 09:33:44
【问题描述】:

我正在尝试使用Dockerfile 从源代码构建v8

FROM ubuntu:20.04

ARG V8_REPO=https://chromium.googlesource.com/chromium/tools/depot_tools.git
ARG ADD_DEPOTTOOLS2PATH='export PATH=/depot_tools:$PATH'

RUN                                         \
apt-get update -y                        && \
apt-get install git -y                   && \
apt-get install vim -y                   && \
apt-get install wget -y                  && \
apt-get install python3 -y               && \
git clone ${V8_REPO}                     && \
echo ${ADD_DEPOTTOOLS2PATH} >> ~/.bashrc && \
source ~/.bashrc

由于某种原因,它在source-ing .bashrc 中失败:

$ docker build --tag host --file .\Dockerfile.txt .
...
#5 47.17 /bin/sh: 1: source: not found
------
executor failed running [... && source ~/.bashrc]: exit code: 127

【问题讨论】:

    标签: bash docker dockerfile


    【解决方案1】:

    RUN is /bin/sh 使用的 shell。 /bin/sh 不提供 source 命令。 试试.-command 而不是source

    【讨论】:

    • 这里还值得一提的是,在每个RUN 命令之后环境都会被重置,并且大多数 Docker 路径不使用 shell 点文件,所以用... && . ~/.bashrc 结束一个RUN 指令可能会做在实践中绝对没有。
    猜你喜欢
    • 1970-01-01
    • 2017-02-23
    • 2018-02-18
    • 2015-08-19
    • 1970-01-01
    • 2021-12-17
    • 1970-01-01
    • 2022-06-29
    • 2020-06-25
    相关资源
    最近更新 更多