0

my docker-compose file as below:

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

My docker file "Dockerfile_Build_Django" as below:

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 as below: only 1 line

Django == 2.2.17

but when I run "docker-compose up", it failed with below errors,

[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

I have been searching for solution for a long time and tried many fixes found via google, no luck so far. any help is appreciated. I feel like getting involved in IT is a waste of life because coding according to guide/user manual for 5 mins then troubleshooting for hours or even days...

Yan Tian
  • 377
  • 3
  • 11
  • Yes, sometimes it's a waste of life... Could you also add the requirements.txt? – Petronella Apr 08 '21 at 09:36
  • 1
    Usually if you're getting that error then your `CMD` looks like it has JSON-array syntax, but you've gotten some part of the punctuation wrong (single quotes instead of double, for example); see _e.g._ [Docker image error: “/bin/sh: 1: [python,: not found”](https://stackoverflow.com/questions/32709075/docker-image-error-bin-sh-1-python-not-found). But that doesn't match the files you've included in the question. – David Maze Apr 08 '21 at 10:27
  • @Petronella, sorry for the delay, requirements.txt updated into the post. – Yan Tian Apr 09 '21 at 01:46

1 Answers1

-1

There is mine if it can help :

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"]

I recommend you to use gunicorn to run you server in production env.

Luckyloup
  • 19
  • 5