質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
Django

DjangoはPythonで書かれた、オープンソースウェブアプリケーションのフレームワークです。複雑なデータベースを扱うウェブサイトを開発する際に必要な労力を減らす為にデザインされました。

uWSGI

uWSGIは、PythonでWebサービスを動かすアプリケーションサーバの一つです。WSGI(Web Server Gateway Interface)アプリケーションコンテナの一種で、WSGIに則ったDjangoやFlaskなどで動かすことができます。

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

Q&A

1回答

3297閲覧

djangoとuWSGIをdockerを使用してプロセスを開始したい

sk-sora--ypi

総合スコア530

Django

DjangoはPythonで書かれた、オープンソースウェブアプリケーションのフレームワークです。複雑なデータベースを扱うウェブサイトを開発する際に必要な労力を減らす為にデザインされました。

uWSGI

uWSGIは、PythonでWebサービスを動かすアプリケーションサーバの一つです。WSGI(Web Server Gateway Interface)アプリケーションコンテナの一種で、WSGIに則ったDjangoやFlaskなどで動かすことができます。

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

0グッド

1クリップ

投稿2021/04/01 14:51

#やりたいこと
uWSGIを使用してdjangoをスタートしたい

#ハマっていること
pipenv run uwsgi --http :8000 --module project.project.wsgiを実行した際エラー?かよくわかりませんが下記が出力される

sh

1/django# pipenv run uwsgi --http :8000 --module project.project.wsgi 2*** Starting uWSGI 2.0.19.1 (64bit) on [Thu Apr 1 14:43:04 2021] *** 3compiled with version: 8.3.0 on 01 April 2021 14:41:46 4os: Linux-5.4.0-66-generic #74-Ubuntu SMP Wed Jan 27 22:54:38 UTC 2021 5nodename: 0db005f1f7dc 6machine: x86_64 7clock source: unix 8pcre jit disabled 9detected number of CPU cores: 2 10current working directory: /django 11detected binary path: /root/.local/share/virtualenvs/django-tLoTjnL9/bin/uwsgi 12uWSGI running as root, you can use --uid/--gid/--chroot options 13*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 14*** WARNING: you are running uWSGI without its master process manager *** 15your memory page size is 4096 bytes 16detected max file descriptor number: 1048576 17lock engine: pthread robust mutexes 18thunder lock: disabled (you can enable it with --thunder-lock) 19uWSGI http bound on :8000 fd 4 20spawned uWSGI http 1 (pid: 13) 21uwsgi socket 0 bound to TCP address 127.0.0.1:38883 (port auto-assigned) fd 3 22uWSGI running as root, you can use --uid/--gid/--chroot options 23*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 24Python version: 3.9.2 (default, Mar 31 2021, 12:21:33) [GCC 8.3.0] 25*** Python threads support is disabled. You can enable it with --enable-threads *** 26Python main interpreter initialized at 0x560431aadf00 27uWSGI running as root, you can use --uid/--gid/--chroot options 28*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 29your server socket listen backlog is limited to 100 connections 30your mercy for graceful operations on workers is 60 seconds 31mapped 72904 bytes (71 KB) for 1 cores 32*** Operational MODE: single process *** 33WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x560431aadf00 pid: 8 (default app) 34uWSGI running as root, you can use --uid/--gid/--chroot options 35*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 36*** uWSGI is running in multiple interpreter mode *** 37spawned uWSGI worker 1 (and the only) (pid: 8, cores: 1)

上記が出ている際にポートを確認したが開いている様子がない

sh

1$ curl localhost:8000 2curl: (7) Failed to connect to localhost port 8000: Connection refused

##プロジェクト構造

/django$ tree . ├── Dockerfile ├── Pipfile ├── Pipfile.lock └── project ├── db.sqlite3 ├── manage.py ├── project │   ├── __init__.py │   ├── asgi.py │   ├── settings.py │   ├── urls.py │   └── wsgi.py └── trades ├── __init__.py ├── admin.py ├── apps.py ├── migrations │   └── __init__.py ├── models.py ├── tests.py └── views.py

django/project/project/wsgi.pyはstartproject時のまま使用していますが
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.project.settings')のみプロジェクト構造に合わせています

やったこと

!!! no internal routing support, rebuild with pcre support !!!
の一文で検索すると下記ページが出てきたため、
rebuild uwsgi with pcre support - Stack Overflow
sudo apt-get install libpcre3 libpcre3-devを行なったのち
pipenv installにてuwsgiをインストールしています

Dockerfile

1FROM python:slim 2 3WORKDIR /django 4 5COPY Pipfile Pipfile.lock /django/ 6 7RUN apt-get update && apt-get install gcc libpcre3 libpcre3-dev -y 8 9RUN python -m pip install --upgrade pip \ 10 && python -m pip install pipenv \ 11 && pipenv install

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

どのようにしてコンテナをビルドしたのでしょうか。
ビルドした際のコマンド (docker build ~~~) について教えて下さい。

また、ビルド出来ているなら試しに、 docker run --rm -ti イメージ名 bash としてコンテナの中に入って、想定通りのイメージになっているか確認してみてはいかがでしょうか。

イメージ名がわからないなら docker image ls で確認してみてください。

投稿2021/04/22 14:16

yassan

総合スコア26

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問