Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x Dockerize Django应用程序失败,错误为“/bin/sh:[蟒蛇3,:未找到”;_Python 3.x_Django_Docker_Docker Compose - Fatal编程技术网

Python 3.x Dockerize Django应用程序失败,错误为“/bin/sh:[蟒蛇3,:未找到”;

Python 3.x Dockerize Django应用程序失败,错误为“/bin/sh:[蟒蛇3,:未找到”;,python-3.x,django,docker,docker-compose,Python 3.x,Django,Docker,Docker Compose,我的docker编写文件如下: Django_2.2: build: context: . dockerfile: Dockerfile_Build_Django # Give an image name/tag image: django_2.2:iot container_name: Django_2.2 depends_on: - Django_Mongo_4.2.12 networks: sw_Django: ipv4_address: 192.168.110

我的docker编写文件如下:

Django_2.2:
build:
  context: .
  dockerfile: Dockerfile_Build_Django
# Give an image name/tag
image: django_2.2:iot 
container_name: Django_2.2
depends_on: 
  - Django_Mongo_4.2.12
networks:
  sw_Django:
    ipv4_address: 192.168.110.12
ports:
  - 8000:80
restart: always
volumes: 
  - type: volume
    source: vol_django_codes
    target: /usr/src/app
FROM python:3.9.3-alpine3.13
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
COPY . .
RUN pip install -r requirements.txt
# CMD ["python","./IoTSite/manage.py","runserver","0.0.0.0:80"]
CMD python ./IoTSite/manage.py runserver 0.0.0.0:80
我的docker文件“Dockerfile\u Build\u Django”如下所示:

Django_2.2:
build:
  context: .
  dockerfile: Dockerfile_Build_Django
# Give an image name/tag
image: django_2.2:iot 
container_name: Django_2.2
depends_on: 
  - Django_Mongo_4.2.12
networks:
  sw_Django:
    ipv4_address: 192.168.110.12
ports:
  - 8000:80
restart: always
volumes: 
  - type: volume
    source: vol_django_codes
    target: /usr/src/app
FROM python:3.9.3-alpine3.13
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
COPY . .
RUN pip install -r requirements.txt
# CMD ["python","./IoTSite/manage.py","runserver","0.0.0.0:80"]
CMD python ./IoTSite/manage.py runserver 0.0.0.0:80
requirements.txt如下:仅1行

Django == 2.2.17
但当我运行“docker compose up”时,它失败了,出现以下错误

[root@Django]# docker logs Django_2.2 
/bin/sh: [python3,: not found
/bin/sh: [python3,: not found
/bin/sh: [python3,: not found
/bin/sh: [python3,: not found
/bin/sh: [python3,: not found
/bin/sh: [python3,: not found
/bin/sh: [python3,: not found
/bin/sh: [python3,: not found
我一直在寻找解决方案很长一段时间,并尝试了许多通过谷歌找到的修复,目前为止没有运气。任何帮助都表示感谢。
我觉得参与其中是浪费生命,因为根据指南/用户手册编码5分钟,然后故障排除数小时甚至数天…

如果它能帮助:

FROM python:3.8
ADD project /app
WORKDIR /app

#(for production only)
#RUN pip3 install --default-timeout=10 --no-cache-dir -r requirements.txt
RUN pip3 install --upgrade pip
RUN pip3 install -r requirements.txt

EXPOSE 80
CMD ["gunicorn", "project.wsgi:application", "--bind", "0.0.0.0:80", "--reload"]

我建议您使用gunicorn在production env中运行服务器。

是的,有时这是浪费生命……您是否也可以添加requirements.txt?通常,如果您遇到该错误,那么您的
CMD
看起来像是有JSON数组语法,但您的标点符号有一部分错误(例如,单引号而不是双引号);请参见示例…,但这与您在问题中包含的文件不匹配。@Petronella,很抱歉延迟,requirements.txt已更新到帖子中。感谢分享,尽管我是gunicorn的新手。我会记住这一点。