【发布时间】:2021-07-04 03:48:02
【问题描述】:
我的 docker-compose 文件如下:
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
我的 docker 文件“Dockerfile_Build_Django”如下:
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
我一直在寻找解决方案,并尝试了许多通过 google 找到的修复程序,到目前为止没有运气。任何帮助表示赞赏。 我觉得涉足 IT 是在浪费生命,因为根据指南/用户手册进行 5 分钟编码,然后花费数小时甚至数天进行故障排除......
【问题讨论】:
-
是的,有时候是在浪费生命……能不能也把requirements.txt加进去?
-
通常,如果您遇到该错误,那么您的
CMD看起来像它具有 JSON 数组语法,但您的标点符号的某些部分错误(例如,单引号而不是双引号);参见例如 Docker image error: “/bin/sh: 1: [python,: not found”。但这与您在问题中包含的文件不匹配。 -
@Petronella,抱歉耽搁了,requirements.txt 已更新到帖子中。
标签: python-3.x django docker docker-compose