Where docker gets the worker from if it is not specified in the compose file (it was before, but deleted and docker still pulls it)

I want to run the application from docker, there was a problem that worker_1 connects to localhost, but a different address was specified in the env

.env

DATABASE_URL=postgres://db_user:db_password@db/db_name
#DATABASE_URL=postgres://postgres:123@127.0.0.1/olx-killer
# Redis
#REDIS_URL=redis://localhost:6379
REDIS_URL=redis://redis:6379

I decided to comment out everything related to redis and celery both in settings and env, also deleted worker from docker compose file, but it still takes it from somewhere and tries to connect to local host.

settings.py

# Redis
#REDIS_URL = os.getenv('REDIS_URL', 'redis://redis:6379/')
#REDIS_CACHE_URL = f'{REDIS_URL}/1'


# Celery
#CELERY_TIMEZONE = TIME_ZONE
#CELERY_TASK_TRACK_STARTED = True
#CELERY_BROKER_URL = REDIS_URL
#CELERY_RESULT_BACKEND = None
#CELERY_TASK_SERIALIZER = 'json'
#CELERY_RESULT_SERIALIZER = 'json'
#CELERY_ACCEPT_CONTENT = ['json']

docker-compose.yml

volumes:
  pg_data:
    driver: local

x-base: &base-backend
  build: .
  volumes:
    - .:/code:delegated
  depends_on:
    - db

services:
  backend:
    <<: *base-backend
    ports:
      - "8000:8000"
    env_file: .env
    environment:
      - DJANGO_SETTINGS_MODULE=settings.main
    entrypoint: ["/code/entrypoint.sh"]
    depends_on:
      - db
    restart: unless-stopped

  db:
    image: postgres:13
    volumes:
      - "pg_data:/var/lib/postgresql/data"
    environment:
      POSTGRES_DB: db_name
      POSTGRES_USER: db_user
      POSTGRES_PASSWORD: db_password
    ports:
      - "5432:5432"
    restart: unless-stopped

Traceback

I tried deleting all the images

docker-compose down --volumes --remove-orphans docker system prune -a --volumes but it doesn't work.

Let me help you to find the issue: The traceback you shared says that worker_1 is still going up even after you removed it from your docker-compose.yml file.

Do you have more than docker-compose files? maybe one for development and one for production?

Maybe there is something in entrypoint.sh firing up celery?

The problem was solved by reinstalling the docker and restarting the computer

Вернуться на верх