Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the line Run pip install Flask in Dockerfile #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ammarovehub
Copy link

When running the container on myfirstapp image, you will get the following error

docker container run -p 8888:5000 --name myfirstapp myfirstapp
Traceback (most recent call last):
File "/usr/src/app/app.py", line 2, in
from flask import Flask
File "/usr/local/lib/python3.10/dist-packages/flask/init.py", line 19, in
from jinja2 import Markup, escape
ImportError: cannot import name 'Markup' from 'jinja2' (/usr/local/lib/python3.10/dist-packages/jinja2/init.py)

The solution is

1-add the following line in Dockerfile

RUN pip install Flask

under

Install python and pip

RUN apt-get update -y
RUN apt-get install -y python3 python3-pip python3-dev build-essential.

2- Update the requirements.txt
Flask==2 instead Flask==1.0

3.- add the -d flag to the command docker container run -p 8888:5000 --name myfirstapp myfirstapp to let it run in the background
docker container run -d -p 8888:5000 --name myfirstapp myfirstapp

When running the container on myfirstapp image, you will get the following error

 docker container run -p 8888:5000 --name myfirstapp myfirstapp
Traceback (most recent call last):
  File "/usr/src/app/app.py", line 2, in <module>
    from flask import Flask
  File "/usr/local/lib/python3.10/dist-packages/flask/__init__.py", line 19, in <module>
    from jinja2 import Markup, escape
ImportError: cannot import name 'Markup' from 'jinja2' (/usr/local/lib/python3.10/dist-packages/jinja2/__init__.py)

The solution is 

1-add the following line in Dockerfile 

RUN pip install Flask

under 

# Install python and pip
    RUN apt-get update -y
    RUN apt-get install -y python3 python3-pip python3-dev build-essential.

2- Update the requirements.txt
Flask==2 instead Flask==1.0

3.- add the  -d flag to the command   docker container run -p 8888:5000 --name myfirstapp myfirstapp to let it run in the background
docker container run -d -p 8888:5000 --name myfirstapp myfirstapp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant