I am encountering an issue when running my Django project inside a Docker container using the Python 3.11.1 image

45 Views Asked by At

I am encountering an issue when running my Django project inside a Docker container using the Python 3.11.1 image. The error message I am receiving is:

Locale folder already exists. Skipping creation.
lang en
Internal Server Error: /
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
...
File "/DjangoProject/json_to_po.py", line 70, in number_format
locale.setlocale(locale.LC_ALL, lang)
File "/usr/local/lib/python3.11/locale.py", line 626, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting
[08/Jan/2024 09:41:17] "GET / HTTP/1.1" 500 60719

My Dockerfile is as follows:

FROM python:3.11.1

# Set environment variables
ENV PYTHONUNBUFFERED 1
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8

# Set working directory
WORKDIR /DjangoProject
COPY . /DjangoProject

# Install dependencies
RUN apt-get update && apt-get install -y locales
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8

RUN pip install -r requirements.txt
RUN python manage.py makemigrations
RUN python manage.py migrate

I suspect that the issue is related to the locale settings. How can I resolve this "unsupported locale setting" error in my Dockerized Django project using Python 3.11.1?

0

There are 0 best solutions below