I have a simple Python script with this header
from flask import Flask
app = Flask(__name__)
@app.route('/')
import os
import pandas as pd
from statsmodels.formula.api import ols
import statsmodels.api as sm
I have installed GitHub Desktop, Docker Desktop
I have created a folder in that I have
(.venv) (base) angel@Angels-MacBook-Pro docker % ls
Dockerfile app.py compose.yaml requirements.txt
In requirements.txt
I have
(.venv) (base) angel@Angels-MacBook-Pro docker % cat requirements.txt
blinker==1.6.2
click==8.1.6
colorama==0.4.6
Flask==2.3.2
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.3
Werkzeug==2.3.6
gunicorn==21.2.0
This is the commands I have run so far
docker init
Then this one returns error
(.venv) (base) angel@Angels-MacBook-Pro docker % docker compose up --build
[+] Building 3.9s (14/14) FINISHED docker:desktop-linux
=> [server internal] load .dockerignore 0.1s
=> => transferring context: 680B 0.1s
=> [server internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 1.63kB 0.1s
=> [server] resolve image config for docker.io/docker/dockerfile:1 2.3s
=> [server auth] docker/dockerfile:pull token for registry-1.docker.io 0.0s
=> CACHED [server] docker-image://docker.io/docker/dockerfile:1@sha256:ac85f380a63b13dfcefa89046420e1781752bab202122f8f50032edf31b 0.0s
=> [server internal] load metadata for docker.io/library/python:3.9.12-slim 1.3s
=> [server auth] library/python:pull token for registry-1.docker.io 0.0s
=> [server base 1/5] FROM docker.io/library/python:3.9.12-slim@sha256:364ada4cb4f943b603d330cbb3d26f689c8b54de51cb12bad1202de7dba3 0.0s
=> [server internal] load build context 0.0s
=> => transferring context: 1.39kB 0.0s
=> CACHED [server base 2/5] WORKDIR /app 0.0s
=> CACHED [server base 3/5] RUN adduser --disabled-password --gecos "" --home "/nonexistent" --shell "/sbin/nologi 0.0s
=> CACHED [server base 4/5] RUN --mount=type=cache,target=/root/.cache/pip --mount=type=bind,source=requirements.txt,target=re 0.0s
=> [server base 5/5] COPY . . 0.0s
=> [server] exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:c207ecf929eb3dc4f172db22e56a19e7b89892fcdc31da80501cb3524e137f9d 0.0s
=> => naming to docker.io/library/docker-server 0.0s
[+] Running 1/1
✔ Container docker-server-1 Recreated 0.1s
Attaching to docker-server-1
docker-server-1 | [2023-09-22 11:09:20 +0000] [8] [INFO] Starting gunicorn 21.2.0
docker-server-1 | [2023-09-22 11:09:20 +0000] [8] [INFO] Listening at: http://0.0.0.0:8000 (8)
docker-server-1 | [2023-09-22 11:09:20 +0000] [8] [INFO] Using worker: sync
docker-server-1 | [2023-09-22 11:09:20 +0000] [9] [INFO] Booting worker with pid: 9
docker-server-1 | [2023-09-22 11:09:20 +0000] [9] [ERROR] Exception in worker process
docker-server-1 | Traceback (most recent call last):
docker-server-1 | File "/usr/local/lib/python3.9/site-packages/gunicorn/arbiter.py", line 609, in spawn_worker
docker-server-1 | worker.init_process()
docker-server-1 | File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 134, in init_process
docker-server-1 | self.load_wsgi()
docker-server-1 | File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
docker-server-1 | self.wsgi = self.app.wsgi()
docker-server-1 | File "/usr/local/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi
docker-server-1 | self.callable = self.load()
docker-server-1 | File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
docker-server-1 | return self.load_wsgiapp()
docker-server-1 | File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
docker-server-1 | return util.import_app(self.app_uri)
docker-server-1 | File "/usr/local/lib/python3.9/site-packages/gunicorn/util.py", line 371, in import_app
docker-server-1 | mod = importlib.import_module(module)
docker-server-1 | File "/usr/local/lib/python3.9/importlib/__init__.py", line 122, in import_module
docker-server-1 | raise TypeError(msg.format(name))
docker-server-1 | TypeError: the 'package' argument is required to perform a relative import for '.venv.lib.python3.9.site-packages.eventlet.wsgi'
docker-server-1 | [2023-09-22 11:09:20 +0000] [9] [INFO] Worker exiting (pid: 9)
docker-server-1 | [2023-09-22 11:09:20 +0000] [8] [ERROR] Worker (pid:9) exited with code 3
docker-server-1 | [2023-09-22 11:09:20 +0000] [8] [ERROR] Shutting down: Master
docker-server-1 | [2023-09-22 11:09:20 +0000] [8] [ERROR] Reason: Worker failed to boot.
docker-server-1 exited with code 3
yaml
# Comments are provided throughout this file to help you get started.
# If you need more help, visit the Docker compose reference guide at
# https://docs.docker.com/compose/compose-file/
# Here the instructions define your application as a service called "server".
# This service is built from the Dockerfile in the current directory.
# You can add other services your application may depend on here, such as a
# database or a cache. For examples, see the Awesome Compose repository:
# https://github.com/docker/awesome-compose
services:
server:
build:
context: .
ports:
- 8000:8000
# The commented out section below is an example of how to define a PostgreSQL
# database that your application can use. `depends_on` tells Docker Compose to
# start the database before your application. The `db-data` volume persists the
# database data between container restarts. The `db-password` secret is used
# to set the database password. You must create `db/password.txt` and add
# a password of your choosing to it before running `docker compose up`.
# depends_on:
# db:
# condition: service_healthy
# db:
# image: postgres
# restart: always
# user: postgres
# secrets:
# - db-password
# volumes:
# - db-data:/var/lib/postgresql/data
# environment:
# - POSTGRES_DB=example
# - POSTGRES_PASSWORD_FILE=/run/secrets/db-password
# expose:
# - 5432
# healthcheck:
# test: [ "CMD", "pg_isready" ]
# interval: 10s
# timeout: 5s
# retries: 5
# volumes:
# db-data:
# secrets:
# db-password:
# file: db/password.txt
Dockerfile
FROM python:3.9
WORKDIR /docker
COPY . /docker
RUN pip install -r requirements.txt
CMD ["python", "./app.py"]
compose.yaml
andDockerfile
here as well. The latter can be deduced from your log but it'd be nice to view the former. $\endgroup$