-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Open
Description
The https://github.com/docker/awesome-compose/blob/master/official-documentation-samples/django/README.md example instructions fail with
docker compose run web django-admin startproject composeexample .
...
File "/usr/local/lib/python3.13/site-packages/django/core/management/commands/startproject.py", line 2, in <module>
from django.core.management.templates import TemplateCommand
File "/usr/local/lib/python3.13/site-packages/django/core/management/templates.py", line 1, in <module>
import cgi
ModuleNotFoundError: No module named 'cgi'
The cgi
module was removed from Python, such that django crashes when used with the latest official Python Docker image. The Dockerfile base image should be specified to avoid this issue. For example:
# syntax=docker/dockerfile:1
FROM python:3.11
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/
works as expected.
Metadata
Metadata
Assignees
Labels
No labels