how to install flask-mysqldb library in a docker container?

  docker, dockerfile

I am learning docker and K8s, and so I am doing a practice in which I am trying to dockerize a simple python app in flask and connect it with anoter container running MySQL. The thing is that in my requirements.txt file I just have these 3 dependencies flask==1.1 flask-mysqldb==0.2.0 json-logging but when I execute the Dockerfile:

FROM python:3.7-alpine
WORKDIR /code
ENV FLASK_APP App.py
ENV FLASK_RUN_HOST 0.0.0.0
# RUN apk add --no-cache gcc musl-dev linux-headers
COPY ./myapp/requirements.txt requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
ADD ./myapp .
EXPOSE 3001
CMD ["flask", "run"]

I get an error saying that a version that satisfies the requierment mysqlclient have not been found. I have tried with and without the version (0.2.0) in the requirements.txt file and running the app in local it works fine by just executing pip install flask-mysqldb any hint why in local works fine and I get this error in my container? This is the output I get when executing the docker build command

#8 6.985 INFO: pip is looking at multiple versions of <Python from Requires-Python> to determine which version is compatible with other requirements. This 
could take a while.
#8 6.985 INFO: pip is looking at multiple versions of flask to determine which version is compatible with other requirements. This could take a while.     
#8 6.985 ERROR: Could not find a version that satisfies the requirement mysqlclient (from flask-mysqldb)
#8 6.985 ERROR: No matching distribution found for mysqlclient```

Source: Docker Questions

LEAVE A COMMENT