как жизнь ... У меня проблема с развертыванием моего приложения в docker контейнере. У меня есть docker -compose.yml файл
version: "3"
services:
web:
build: ./web
ports:
- "5000:5000"
links:
- db
db:
build: ./db
Итак, два других файла Docker один для Mon go БД и для Flask WebApp. Для базы данных Mon go просто:
FROM mongo:3.6.4
А для WebApp
# For more information, please refer to https://aka.ms/vscode-docker-python
FROM python:3.8
EXPOSE 5000
# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE 1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED 1
# Install pip requirements
ADD requirements.txt .
RUN python -m pip install -r requirements.txt
WORKDIR /app
ADD . /app
# Switching to a non-root user,
RUN useradd appuser && chown -R appuser /app
USER appuser
# During debugging, this entry point will be overridden.
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "web.app:app"]
Структура моего рабочего пространства VS Code выглядит следующим образом:
Workspace
--db
----Dockerfile
--web
----app.py
----Dockerfile
----requirements.txt
--docker-compose.yml
Я запускаю sudo docker - composer Построить без проблем ... Образ создан
запуск образа БД работает нормально, запуск образа WebAApp с помощью интерактивного запуска ... oups ... с этой ошибкой
~/Dev/RestApi$ docker run --rm -it -p 5000:5000/tcp restapi_web:latest
[2020-05-04 15:14:14 +0000] [1] [INFO] Starting gunicorn 20.0.4
[2020-05-04 15:14:14 +0000] [1] [INFO] Listening at: http://0.0.0.0:5000 (1)
[2020-05-04 15:14:14 +0000] [1] [INFO] Using worker: sync
[2020-05-04 15:14:14 +0000] [7] [INFO] Booting worker with pid: 7
[2020-05-04 15:14:14 +0000] [7] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/base.py", line 119, in init_process
self.load_wsgi()
File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
return self.load_wsgiapp()
File "/usr/local/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python3.8/site-packages/gunicorn/util.py", line 358, in import_app
mod = importlib.import_module(module)
File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'web'
[2020-05-04 15:14:14 +0000] [7] [INFO] Worker exiting (pid: 7)
[2020-05-04 15:14:15 +0000] [1] [INFO] Shutting down: Master
[2020-05-04 15:14:15 +0000] [1] [INFO] Reason: Worker failed to boot.
заранее спасибо за помощь ...