Docker run generates a random string

I’d like to use Docker to deploy a/my containerized Python/Flask web app, which reads and writes from an SQLite database to populate every page/route. (I realize I need a volume for the database.) But I’m truly stumped as to why docker run keeps generating a random string.

Here’s a bit about my project

  • app/
    • public/
    • templates/
    • …init…py
    • requirements.txt
  • db/
    • database.db
    • schema.sql
  • Dockerfile
  • etc.

Run the app locally (first time)

Pre-seed the database and create db/database.db:

(venv) python3 db/

Install dependencies:

source venv/bin/activate
(venv) cd app
(venv) pip3 install -r requirements.txt

Start the app:

(venv) gunicorn -w 4 -b wsgi:app

Works great.

Dockerfile, build & tag, run

FROM python:3.8-slim
RUN mkdir /app
COPY requirements.txt ./
RUN python -m pip install --upgrade pip \
    && pip install --no-cache-dir -r requirements.txt
COPY . /app
CMD ["gunicorn", "-w", "4", "-b", "", "wsgi:app"]

All good.

docker build -t tucker/stripe-python-flask-app .
docker tag tucker/stripe-python-flask-app:latest tucker/stripe-python-flask-app:1.0

Problem (below), docker run generates a random string? Any suggestions on what this could be is appreciated.

docker run -d -p 8000:8000 tucker/stripe-python-flask-app:1.0

The output of docker run -d is the container id. As each execution of that command creates a new container, of course the container id will be different for new created container.

1 Like

@meyay Oops, thanks very much. I removed the -d flag. Though, I’m getting a Gunicorn error now. I’ll start searching for solutions/ideas.

ModuleNotFoundError: No module named 'wsgi'
[2022-10-02 21:31:29 +0000] [8] [INFO] Worker exiting (pid: 8)
[2022-10-02 21:31:29 +0000] [1] [INFO] Shutting down: Master
[2022-10-02 21:31:29 +0000] [1] [INFO] Reason: Worker failed to boot.