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
    • app.py
    • config.py
    • requirements.txt
    • wsgi.py
  • db/
    • database.db
    • init_db.py
    • schema.sql
  • build.sh
  • Dockerfile
  • etc.

Run the app locally (first time)

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

(venv) python3 db/init_db.py

Install dependencies:

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

Start the app:

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

Works great.

Dockerfile, build & tag, run

FROM python:3.8-slim
RUN mkdir /app
WORKDIR /app
COPY requirements.txt ./
RUN python -m pip install --upgrade pip \
    && pip install --no-cache-dir -r requirements.txt
COPY . /app
EXPOSE 8000
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:8000", "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
0c000b0c64998ac4cdbb7f38abd37b7bdec973c35c8cd3a8062dae67fc0edeed

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.