Issue with Dockerfile, Centos and Flask

Hello, I have the following Dockerfile:

FROM centos:centos7.9.2009
RUN yum update -y
RUN yum install -y python
RUN yum install -y python3-pip
RUN pip3 install flask
COPY app.py /opt/app.py
ENTRYPOINT FLASK_APP=/opt/app.py flask run --host=0.0.0.0

When I run “docker build . -t test123” it finishes successfully

But when I run “docker run test123” it fails with the following:

Traceback (most recent call last):
  File "/usr/local/bin/flask", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib64/python3.6/site-packages/flask/cli.py", line 995, in main
    cli.main(args=sys.argv[1:])
  File "/usr/local/lib64/python3.6/site-packages/flask/cli.py", line 601, in main
    return super().main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1034, in main
    _verify_python_env()
  File "/usr/local/lib/python3.6/site-packages/click/_unicodefun.py", line 100, in _verify_python_env
    raise RuntimeError("\n\n".join(extra))
RuntimeError: Click will abort further execution because Python was configured to use ASCII as encoding for the environment. Consult https://click.palletsprojects.com/unicode-support/ for mitigation steps.

This system lists some UTF-8 supporting locales that you can pick from. The following suitable locales were discovered: en_US.utf8

Tried to add to Dockerfile, did not help

RUN export LC_CTYPE=en_US.UTF-8
RUN export LC_ALL=en_US.UTF-8

Please suggest, how this situation can be fixed?

I think there should be a
RUN yum install -y epel-release
RUN yum install -y python3 python3-pip
before
RUN pip3 install flask

Hi,

I have been facing the same issue tried both options of setting env and also adding “RUN yum install -y epel-release” but still no luck.

Could anyone resolve the issue?

Thank you,
Pradeep.

Hi,

Just setting the env to proper location has resolved the issue, I was setting it up as “en_IN.UTF-8”, but the server time zone was “en_US.UTF8”, and also for env settting instead of “RUN” use “ENV” to set env variable.

ENV export LC_CTYPE=en_US.UTF-8
ENV export LC_ALL=en_US.UTF-8

Thank you,
Pradeep.