After trying to contain the applications, Celery events stopped being processed [closed]

I wrote a simple Django website for buying tickets, Celery, when the user starts the process of paying for a seat, it is booked. if after n seconds he still hasn't paid, then it is released using Celery.

when I launched the site locally (using worker and redis manually), everything worked correctly. Before conterization, I changed the settings for celery:

CELERY_BROKER_URL = 'redis://localhost:6379/0'
CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'

I changed localhost to redis because I heard that Docker makes the network name of the container what is specified in docker-compose

строка настройки:

FROM python:3.11-slim

WORKDIR /app

COPY . .

RUN pip3 install -r requirements.txt

EXPOSE 8000

CMD ["python3", "Tickets/manage.py", "runserver", "0.0.0.0:8000"]

окно настройки-создание:

services:
  web:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "8000:8000"
    container_name: ticket-web
  worker:
    image: ticket-web
    working_dir: /app/Tickets
    command: celery -A Tickets worker
    depends_on:
      - redis
      - web

  redis:
    image: redis:6-alpine
    ports:
      - "6379:6379"

celery.py:

import os
from celery import Celery

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Tickets.settings')

app = Celery('Tickets')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()
app.conf.update(
    timezone='Europe/Moscow',  # Set your preferred timezone
    enable_utc=False,
)

app.autodiscover_tasks()


@app.task(bind=True, ignore_result=True)
def debug_task(self):
    print(f'Request: {self.request!r}')

инициализировать:

from __future__ import absolute_import, unicode_literals
from .celery import app as celery_app

__all__ = ('celery_app',)

worker logs:

SecurityWarning: You're running the worker with superuser privileges: this is
absolutely not recommended!

Please specify a different user using the --uid option.

User information: uid=0 euid=0 gid=0 egid=0

  warnings.warn(SecurityWarning(ROOT_DISCOURAGED.format(
 
 -------------- celery@4f22dd11a102 v5.5.2 (immunity)
--- ***** ----- 
-- ******* ---- Linux-6.10.14-linuxkit-aarch64-with-glibc2.36 2025-07-03 18:01:06
- *** --- * --- 
- ** ---------- [config]
- ** ---------- .> app:         Tickets:0xffffa1a7fad0
- ** ---------- .> transport:   redis://redis:6379/0
- ** ---------- .> results:     redis://redis:6379/0
- *** --- * --- .> concurrency: 8 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** ----- 
 -------------- [queues]
                .> celery           exchange=celery(direct) key=celery
Вернуться на верх