Docker 运行 找不到可执行文件 "uwsgi"
Docker run cannot find executable "uwsgi"
我正在尝试使用 Docker 部署一个 falcon 应用程序。这是我的 Docker 文件:
FROM python:2-onbuild
# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
ADD . /app
RUN pip install -r ./requirements.txt
RUN pip install uwsgi
EXPOSE 8000
CMD ["uwsgi", "--http”, " :8000" , "—wsgi-file”, "falconapp.wsgi"]
但是我一直收到错误提示:
/bin/sh: 1: [uwsgi,: not found
我已经在本地目录中尝试了 运行 uwsgi,它与命令配合使用效果很好:
uwsgi --http :8000 --wsgi-file falconapp.wsgi
为什么 Docker 在这种情况下不起作用???
这是日志,我很确定 uwsgi 已安装:
Step 5/7 : RUN pip install uwsgi
---> Running in 2df7c8e018a9
Collecting uwsgi
Downloading uwsgi-2.0.17.tar.gz (798kB)
Building wheels for collected packages: uwsgi
Running setup.py bdist_wheel for uwsgi: started
Running setup.py bdist_wheel for uwsgi: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/94/c9/63/e7aef2e745bb1231490847ee3785e3d0b5f274e1f1653f89c5
Successfully built uwsgi
Installing collected packages: uwsgi
Successfully installed uwsgi-2.0.17
Removing intermediate container 2df7c8e018a9
---> cb71648306bd
Step 6/7 : EXPOSE 8000
---> Running in 40daaa0d5efa
Removing intermediate container 40daaa0d5efa
---> 39c75687a157
Step 7/7 : CMD ["uwsgi", "--http”, " :8000" , "—wsgi-file”, "falconapp.wsgi"]
---> Running in 67e6eb29f3e0
Removing intermediate container 67e6eb29f3e0
---> f33181adbcfa
Successfully built f33181adbcfa
Successfully tagged image_heatmap:latest
dan@D-MacBook-Pro:~/Documents/falconapp_api$ docker run -p 8000:80 small_runner
/bin/sh: 1: [uwsgi,: not found
我在 CMD 中看到一些不正确的语法,请使用这个:
CMD ["uwsgi", "--http", " :8000" , "--wsgi-file", "falconapp.wsgi"]
有些双引号不正确,--
不在 wsgi-file
之前。
很多时候,您必须为可执行文件编写完整的补丁。如果你去你的容器和 运行 这个命令 whereis uwsgi
它会告诉你它在 /usr/local/bin/uwsgi
所以你的 CMD 应该是相同的形式:
CMD ["/usr/local/bin/uwsgi", "--http", " :8000" , "--wsgi-file", "falconapp.wsgi"]
我正在尝试使用 Docker 部署一个 falcon 应用程序。这是我的 Docker 文件:
FROM python:2-onbuild
# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
ADD . /app
RUN pip install -r ./requirements.txt
RUN pip install uwsgi
EXPOSE 8000
CMD ["uwsgi", "--http”, " :8000" , "—wsgi-file”, "falconapp.wsgi"]
但是我一直收到错误提示:
/bin/sh: 1: [uwsgi,: not found
我已经在本地目录中尝试了 运行 uwsgi,它与命令配合使用效果很好:
uwsgi --http :8000 --wsgi-file falconapp.wsgi
为什么 Docker 在这种情况下不起作用???
这是日志,我很确定 uwsgi 已安装:
Step 5/7 : RUN pip install uwsgi
---> Running in 2df7c8e018a9
Collecting uwsgi
Downloading uwsgi-2.0.17.tar.gz (798kB)
Building wheels for collected packages: uwsgi
Running setup.py bdist_wheel for uwsgi: started
Running setup.py bdist_wheel for uwsgi: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/94/c9/63/e7aef2e745bb1231490847ee3785e3d0b5f274e1f1653f89c5
Successfully built uwsgi
Installing collected packages: uwsgi
Successfully installed uwsgi-2.0.17
Removing intermediate container 2df7c8e018a9
---> cb71648306bd
Step 6/7 : EXPOSE 8000
---> Running in 40daaa0d5efa
Removing intermediate container 40daaa0d5efa
---> 39c75687a157
Step 7/7 : CMD ["uwsgi", "--http”, " :8000" , "—wsgi-file”, "falconapp.wsgi"]
---> Running in 67e6eb29f3e0
Removing intermediate container 67e6eb29f3e0
---> f33181adbcfa
Successfully built f33181adbcfa
Successfully tagged image_heatmap:latest
dan@D-MacBook-Pro:~/Documents/falconapp_api$ docker run -p 8000:80 small_runner
/bin/sh: 1: [uwsgi,: not found
我在 CMD 中看到一些不正确的语法,请使用这个:
CMD ["uwsgi", "--http", " :8000" , "--wsgi-file", "falconapp.wsgi"]
有些双引号不正确,--
不在 wsgi-file
之前。
很多时候,您必须为可执行文件编写完整的补丁。如果你去你的容器和 运行 这个命令 whereis uwsgi
它会告诉你它在 /usr/local/bin/uwsgi
所以你的 CMD 应该是相同的形式:
CMD ["/usr/local/bin/uwsgi", "--http", " :8000" , "--wsgi-file", "falconapp.wsgi"]