在管道路径中找不到命令



>编辑:这已解决,请参阅下面的答案

我第一次尝试使用 Docker/Jenkins 部署一些软件,但我遇到了一些路径问题。

这是当前的 Dockerfile:

WORKDIR /usr/src/app
COPY ./ .
RUN pip install pipenv
RUN pipenv install --ignore-pipfile
ENV PATH="${PATH}:/usr/src/app"
RUN pipenv run echo $PATH
RUN pwd
RUN ls
RUN pipenv run whereis run
RUN pipenv run run

当我尝试使用 Jenkins 构建 docker 镜像时,我得到以下输出:

09:19:48   ---> Running in ff1a52b2e299
09:19:48  Removing intermediate container ff1a52b2e299
09:19:48   ---> 67355de18e72
09:19:48  Step 7/11 : RUN pipenv run echo $PATH
09:19:48   ---> Running in 5cb904118910
09:19:49  /usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/src/app
09:19:49  Removing intermediate container 5cb904118910
09:19:49   ---> 0df62985c94d
09:19:49  Step 8/11 : RUN pwd
09:19:49   ---> Running in 4e79f53b581f
09:19:49  /usr/src/app
09:19:50  Removing intermediate container 4e79f53b581f
09:19:50   ---> 563ab4218eba
09:19:50  Step 9/11 : RUN ls
09:19:50   ---> Running in fbc7670633d1
09:19:50  Dockerfile
09:19:50  Jenkinsfile
09:19:50  Pipfile
09:19:50  Pipfile.lock
09:19:50  README.md
09:19:50  alembic.ini
09:19:50  run.bat
09:19:50  run.sh
09:19:50  trendanalyse
09:19:51  Removing intermediate container fbc7670633d1
09:19:51   ---> 02a4b76defd0
09:19:51  Step 10/11 : RUN pipenv run whereis run
09:19:51   ---> Running in 70d5448e29b1
09:19:51  run: /usr/src/app/run.bat /usr/src/app/run.sh /usr/src/app/run.bat /usr/src/app/run.sh
09:19:52  Removing intermediate container 70d5448e29b1
09:19:52   ---> 455fc44688ce
09:19:52  Step 11/11 : RUN pipenv run run
09:19:52   ---> Running in b25bf9d5f818
09:19:52  [91mError: the command run could not be found within PATH or Pipfile's [scripts].
09:19:53  [0mThe command '/bin/sh -c pipenv run run' returned a non-zero code: 1

我看不出有什么问题,run.sh 文件在当前路径中,不知道为什么它不会运行。它在我的Windows机器上本地工作,也许是我没有看到的Windows/Linux之间的一些差异?

谢谢!

Dockerfile 有两个问题,我需要添加该行

RUN chmod +x run.sh

此外,我不得不改变

RUN pipenv run run

RUN pipenv run run.sh

(我认为这是由于Windows/Linux的差异(。现在它:)工作

最新更新