简体   繁体   中英

ValueError: Unable to configure handler 'django_file'

I found a Django project and failed to get it running in Docker container in the following way:

  1. git clone git clone https://github.com/NAL-i5K/django-blast.git
  2. $ cat requirements.txt in this files the below dependencies had to be updated:
    • psycopg2==2.8.6

I have the following Dockerfile:

FROM python:2
ENV PYTHONUNBUFFERED=1
RUN apt-get update && apt-get install -y postgresql-client
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/

For docker-compose.yml I use:

version: "3"

services:
  dbik:
    image: postgres
    volumes:
      - ./data/dbik:/var/lib/postgresql/data
      - ./scripts/install-extensions.sql:/docker-entrypoint-initdb.d/install-extensions.sql

    environment:
      - POSTGRES_DB=django_i5k
      - POSTGRES_USER=django
      - POSTGRES_PASSWORD=postgres
    ports:
      - 5432:5432


  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/code
    ports:
      - "8000:8000"
    depends_on:
      - dbik
    links:
      - dbik

$ cat scripts/install-extensions.sql 
CREATE EXTENSION hstore;

I had to change:

$ vim i5k/settings_prod.py
DATABASES = {
    'default': {
    'ENGINE': 'django.db.backends.postgresql_psycopg2',
    'NAME': 'postgres',
    'USER': 'postgres',
    'PASSWORD': 'postgres',
    'HOST': 'db',
    'PORT': '5432',
    }
}

Next, I ran docker-compose up --build

Starting djangoblast_dbik_1 ... 
Starting djangoblast_dbik_1 ... done
Recreating djangoblast_web_1 ... 
Recreating djangoblast_web_1 ... done
Attaching to djangoblast_dbik_1, djangoblast_web_1
dbik_1  | 
dbik_1  | PostgreSQL Database directory appears to contain a database; Skipping initialization
dbik_1  | 
dbik_1  | 2021-05-21 21:05:18.976 UTC [1] LOG:  starting PostgreSQL 13.3 (Debian 13.3-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
dbik_1  | 2021-05-21 21:05:18.976 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
dbik_1  | 2021-05-21 21:05:18.976 UTC [1] LOG:  listening on IPv6 address "::", port 5432
dbik_1  | 2021-05-21 21:05:18.988 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
dbik_1  | 2021-05-21 21:05:18.996 UTC [26] LOG:  database system was shut down at 2021-05-21 21:02:03 UTC
dbik_1  | 2021-05-21 21:05:19.003 UTC [1] LOG:  database system is ready to accept connections
web_1   | Unhandled exception in thread started by <function wrapper at 0x7fa1ec3bebd0>
web_1   | Traceback (most recent call last):
web_1   |   File "/usr/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 229, in wrapper
web_1   |     fn(*args, **kwargs)
web_1   |   File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 107, in inner_run
web_1   |     autoreload.raise_last_exception()
web_1   |   File "/usr/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 252, in raise_last_exception
web_1   |     six.reraise(*_exception)
web_1   |   File "/usr/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 229, in wrapper
web_1   |     fn(*args, **kwargs)
web_1   |   File "/usr/local/lib/python2.7/site-packages/django/__init__.py", line 17, in setup
web_1   |     configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
web_1   |   File "/usr/local/lib/python2.7/site-packages/django/utils/log.py", line 86, in configure_logging
web_1   |     logging_config_func(logging_settings)
web_1   |   File "/usr/local/lib/python2.7/logging/config.py", line 794, in dictConfig
web_1   |     dictConfigClass(config).configure()
web_1   |   File "/usr/local/lib/python2.7/logging/config.py", line 576, in configure
web_1   |     '%r: %s' % (name, e))
web_1   | ValueError: Unable to configure handler 'django_file': [Errno 2] No such file or directory: '/var/log/django/django.log'

What did I miss?

Thank you in advance

From stack trace:

ValueError: Unable to configure handler 'django_file': [Errno 2] No such file or directory: '/var/log/django/django.log'

You need to create /var/log/django directory in your image

RUN mkdir -p /var/log/django

Looked into repo, you'll probably need to create /var/log/i5k too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM