I am trying to learn the baby steps in Docker, following "A Docker Tutorial for Beginners" available in https://docker-curriculum.com/. It is a very basic tutorial, and everything was working, until is wasn't...
The problem occurs when trying to run the catnip image. I use exactly the same Docker file provided, which is:
flask-app> cat Dockerfile
FROM python:3
# set a directory for the app
WORKDIR /usr/src/app
# copy all the files to the container
COPY . .
# install dependencies
RUN pip install --no-cache-dir -r requirements.txt
# tell the port number the container should expose
EXPOSE 5000
# run the command
CMD ["python", "./app.py"]
flask-app>
and, apparently, there are no errors when building the image, only warnings:
flask-app> docker build -t vcmota/catnip .
Sending build context to Docker daemon 8.704kB
Step 1/6 : FROM python:3
3: Pulling from library/python
0c6b8ff8c37e: Pull complete
412caad352a3: Pull complete
e6d3e61f7a50: Pull complete
461bb1d8c517: Pull complete
808edda3c2e8: Pull complete
724cfd2dc19b: Pull complete
8bd4965a24ab: Pull complete
fccd5fa208a8: Pull complete
af1ca64a0eec: Pull complete
Digest: sha256:a7a73f894e756267b2bac3b068e51ad50aa06f16855a9c6b208630d48937796f
Status: Downloaded newer image for python:3
---> e2e732b7951f
Step 2/6 : WORKDIR /usr/src/app
---> Running in afdaaa489bce
Removing intermediate container afdaaa489bce
---> edd50b861260
Step 3/6 : COPY . .
---> 451716174fee
Step 4/6 : RUN pip install --no-cache-dir -r requirements.txt
---> Running in f8ed214822a1
Collecting Flask==1.0
Downloading Flask-1.0-py2.py3-none-any.whl (97 kB)
Collecting Jinja2>=2.10
Downloading Jinja2-3.0.3-py3-none-any.whl (133 kB)
Collecting Werkzeug>=0.14
Downloading Werkzeug-2.0.2-py3-none-any.whl (288 kB)
Collecting click>=5.1
Downloading click-8.0.3-py3-none-any.whl (97 kB)
Collecting itsdangerous>=0.24
Downloading itsdangerous-2.0.1-py3-none-any.whl (18 kB)
Collecting MarkupSafe>=2.0
Downloading MarkupSafe-2.0.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (30 kB)
Installing collected packages: MarkupSafe, Werkzeug, Jinja2, itsdangerous, click, Flask
Successfully installed Flask-1.0 Jinja2-3.0.3 MarkupSafe-2.0.1 Werkzeug-2.0.2 click-8.0.3 itsdangerous-2.0.1
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
WARNING: You are using pip version 21.2.4; however, version 22.0.2 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
Removing intermediate container f8ed214822a1
---> 2416ed873ddc
Step 5/6 : EXPOSE 5000
---> Running in 9b64a53d405f
Removing intermediate container 9b64a53d405f
---> ecc4972d9f53
Step 6/6 : CMD ["python", "./app.py"]
---> Running in abc2342fc55c
Removing intermediate container abc2342fc55c
---> c97241d35432
Successfully built c97241d35432
Successfully tagged vcmota/catnip:latest
flask-app>
But when running the code it simply fails:
flask-app> docker run -p 8888:5000 vcmota/catnip
Traceback (most recent call last):
File "/usr/src/app/./app.py", line 1, in <module>
from flask import Flask, render_template
File "/usr/local/lib/python3.10/site-packages/flask/__init__.py", line 21, in <module>
from .app import Flask, Request, Response
File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 34, in <module>
from .sessions import SecureCookieSessionInterface
File "/usr/local/lib/python3.10/site-packages/flask/sessions.py", line 14, in <module>
from collections import MutableMapping
ImportError: cannot import name 'MutableMapping' from 'collections' (/usr/local/lib/python3.10/collections/__init__.py)
flask-app>
Since this is a containerization app, I understand that the error should have nothing to do with any aspect of my machine, which is hosting Docker. So, is this an issue with the files available for the tutorial or is there something wrong that I am doing?
Thank you all for your attention.