无法访问Docker中的“ uwsgi”网关

我想在Kubernetes中部署Django项目。现在,我正在创建一个docker映像以了解该项目。

Dockerfile

FROM python:3.7 
RUN mkdir /code
WORKDIR /code
ADD requirements.txt /code/
RUN pip3 install -r requirements.txt

docker-compose.yml

version: '3'
services:
  mysql:
    image: mysql:5.7
    volumes:
      - ./mysql:/var/lib/mysql
    expose:
      - "3306"
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=root
      - MYSQL_DATABASE=nlpapp
      - MYSQL_USER=root
      - MYSQL_PASSWORD=root
  nginx:
    image: nginx:alpine
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf
      - ./nginx/conf:/etc/nginx/conf.d
      - ./web/staticfiles:/django_static
    ports:
      - "80:80"
    depends_on:
      - web
  redis:
    image: redis:alpine
    expose:
      - "6379"
    restart: always
  web:
    build: .
    command: uwsgi --ini uwsgi.ini
    working_dir: /code/blog
    volumes:
      - .:/code
    expose:
      - "8000"
    depends_on:
      - mysql
      - redis
  celery:
    build: .
    command: celery -A blog worker -l info
    working_dir: /code/blog
    volumes:
      - .:/code
    depends_on:
      - mysql
      - redis

uwsgi.ini

[uwsgi]
socket=:8000
chdir=/code/blog
module=blog.wsgi:application
pidfile=/tmp/blog-master.pid
master=True
vacuum=True
processes=1
max-requests=5000

requirements.txt

absl-py==0.8.1
amqp==2.5.1
argcomplete==1.10.0
astor==0.8.0
beautifulsoup4==4.8.0
billiard==3.6.1.0
celery==4.3.0
certifi==2019.9.11
cffi==1.13.1
chardet==3.0.4
cloudinary==1.18.2
colorama==0.4.1
contractions==0.0.21
cryptography==2.8
Django==2.2.6
django-bootstrap4==1.0.1
django-celery-beat==1.5.0
django-mysql==3.2.0
django-timezone-field==3.1
django-widget-tweaks==1.4.5
docx2txt==0.8
EbookLib==0.17.1
extract-msg==0.23.1
gast==0.2.2
google-pasta==0.1.7
grpcio==1.24.1
h5py==2.10.0
idna==2.8
IMAPClient==2.1.0
importlib-metadata==0.23
joblib==0.14.0
Keras==2.0.5
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.0
kombu==4.6.5
log3==0.1.7
lxml==4.4.1
Markdown==3.1.1
mock==3.0.5
more-itertools==7.2.0
mysqlclient==1.4.4
nltk==3.4.5
numpy==1.17.3
olefile==0.46
pandas==0.25.2
pdfminer.six==20181108
Pillow==6.2.1
# pkg-resources==0.0.0
protobuf==3.10.0
pyahocorasick==1.4.0
pycparser==2.19
pycryptodome==3.9.0
PyJWT==1.7.1
pypDF2==1.26.0
python-crontab==2.4.0
python-dateutil==2.8.0
python-pptx==0.6.18
pytz==2019.3
PyYAML==5.1.2
redis==3.3.11
requests==2.22.0
schedule==0.6.0
scikit-learn==0.21.3
scipy==1.3.1
six==1.12.0
sklearn==0.0
slug==2.0
slugify==0.0.1
sortedcontainers==2.1.0
soupsieve==1.9.4
SpeechRecognition==3.8.1
sqlparse==0.3.0
tensorboard==2.0.0
tensorflow==2.0.0
tensorflow-estimator==2.0.0
termcolor==1.1.0
textract==1.6.3
textsearch==0.0.17
Theano==1.0.4
tzlocal==1.5.1
unicode-slugify==0.1.3
Unidecode==1.1.1
unsplash-search==0.2.0
urllib3==1.25.6
vine==1.3.0
Werkzeug==0.16.0
wrapt==1.11.2
xlrd==1.2.0
XlsxWriter==1.2.2
zipp==0.6.0

这些是主文件。当我打算在那时候启动docker-compose up命令时,MySQL,Redis,nginx,celery容器运行正常,但WSGI(web)容器未运行并显示错误。

错误:针对Web无法启动服务Web:OCI运行时创建失败:container_linux.go:345:启动容器进程导致“ exec:\“ uwsgi \”:在$ PATH中找不到可执行文件”:未知

错误:启动项目时遇到错误

air6216 回答:无法访问Docker中的“ uwsgi”网关

将命令更改为:

command: /usr/local/bin/uwsgi --ini uwsgi.ini

并确保uwsgi.ini中有/code/blog,并且uwsgi文件中列出了requirements.txt

本文链接:https://www.f2er.com/3154853.html

大家都在问