docker build运行报错source: not found解决分析
运行
FROM python:3.10.10-bullseye RUN . /etc/os-release && cat > /etc/apt/sources.list <<EOF deb http://mirrors.tuna.tsinghua.edu.cn/debian/ ${VERSION_CODENAME} main contrib non-free deb http://mirrors.tuna.tsinghua.edu.cn/debian/ ${VERSION_CODENAME}-updates main contrib non-free deb http://mirrors.tuna.tsinghua.edu.cn/debian/ ${VERSION_CODENAME}-backports main contrib non-free deb http://security.debian.org/debian-security bullseye-security main contrib non-free EOF RUN apt-get update RUN apt-get install -y vim RUN mkdir /code ADD . /code/ WORKDIR /code/PyAV RUN source scripts/activate.sh && pip install --upgrade -r tests/requirements.txt && ./scripts/build-deps && make
报错
─➤ docker build -t ponponon/pyav:0.0.1 . 2 ↵
[+] Building 3.6s (12/12) FINISHED docker:default
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 753B 0.0s
=> [internal] load metadata for docker.io/library/python:3.10.10-bullseye 0.0s
=> [1/8] FROM docker.io/library/python:3.10.10-bullseye 0.0s
=> [internal] load build context 0.5s
=> => transferring context: 3.18MB 0.5s
=> CACHED [2/8] RUN . /etc/os-release && cat > /etc/apt/sources.list <<EOF 0.0s
=> CACHED [3/8] RUN apt-get update 0.0s
=> CACHED [4/8] RUN apt-get install -y vim 0.0s
=> CACHED [5/8] RUN mkdir /code 0.0s
=> [6/8] ADD . /code/ 2.7s
=> [7/8] WORKDIR /code/PyAV 0.0s
=> ERROR [8/8] RUN source scripts/activate.sh && pip install --upgrade -r tests/requirements.txt && ./scripts/build-deps && make 0.3s
------
> [8/8] RUN source scripts/activate.sh && pip install --upgrade -r tests/requirements.txt && ./scripts/build-deps && make:
0.273 /bin/sh: 1: source: not found
------
Dockerfile:18
--------------------
16 | WORKDIR /code/PyAV
17 | CMD ["/bin/bash"]
18 | >>> RUN source scripts/activate.sh && pip install --upgrade -r tests/requirements.txt && ./scripts/build-deps && make
19 |
--------------------
ERROR: failed to solve: process "/bin/sh -c source scripts/activate.sh && pip install --upgrade -r tests/requirements.txt && ./scripts/build-deps && make" did not complete successfully: exit code: 127
问题原因
docker build 默认使用 sh,而不是 bash
而 sh 是没有 source 命令的
所以,解决方案就是把 sh 改成 bash
怎么改?加一行 SHELL ["/bin/bash", "-c"]
解决示例
完整的
FROM python:3.10.10-bullseye RUN . /etc/os-release && cat > /etc/apt/sources.list <<EOF deb http://mirrors.tuna.tsinghua.edu.cn/debian/ ${VERSION_CODENAME} main contrib non-free deb http://mirrors.tuna.tsinghua.edu.cn/debian/ ${VERSION_CODENAME}-updates main contrib non-free deb http://mirrors.tuna.tsinghua.edu.cn/debian/ ${VERSION_CODENAME}-backports main contrib non-free deb http://security.debian.org/debian-security bullseye-security main contrib non-free EOF RUN apt-get update RUN apt-get install -y vim RUN mkdir /code ADD . /code/ WORKDIR /code/PyAV SHELL ["/bin/bash", "-c"] RUN source scripts/activate.sh && pip install --upgrade -r tests/requirements.txt && ./scripts/build-deps && make
以上就是docker build运行报错source: not found解决分析的详细内容,更多关于docker build报错source: not found的资料请关注脚本之家其它相关文章!
相关文章
Docker容器/bin/bash start.sh无法找到not found问题解决
最近在学习联系中遇到一个问题,百度后发现这个需求还是挺常见的,所以下面这篇文章主要给大家介绍了关于Docker容器/bin/bash start.sh无法找到not found问题的解决方法,需要的朋友可以参考下2022-08-08
最新评论