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