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?
CodePudding user response:
RUN export LC_CTYPE=en_US.UTF-8
doesn't work, since each RUN
statement runs in an isolated shell. When the command finishes, all environment variables set are lost.
You should use the ENV statement instead
ENV LC_CTYPE=en_US.UTF-8