我从Divio Django项目模板创建了一个样板项目:
(Python 3.6, Django CMS, HTML 5)
签出存储库将返回两个文件,其中包括一个docker-compose和一个dockerfile。
Docker撰写:version: "2"
services:
web:
build: "."
links:
- "db:postgres"
ports:
- "8000:80"
volumes:
- ".:/app:rw"
- "./data:/data:rw"
command: python manage.py runserver 0.0.0.0:80
env_file: .env-local
db:
image: postgres:9.6-alpine
environment:
POSTGRES_DB: "db"
volumes:
- ".:/app:rw"
所以我试着在本地运行docker-compose run web
启动本地Django CMS实例。但是,我遇到了以下错误:Starting ale_db_1 ... done
/app/addons/aldryn-django/aldryn_config.py:137: RuntimeWarning: no cache configured. Falling back to CACHE_URL=locmem://
RuntimeWarning,
/app/addons/aldryn-django/aldryn_config.py:137: RuntimeWarning: no cache configured. Falling back to CACHE_URL=locmem://
RuntimeWarning,
Unhandled exception in thread started by .wrapper at 0x7f42a18c4950>
Traceback (most recent call last):
File "/virtualenv/lib/python3.6/site-packages/django/utils/autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "/virtualenv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 116, in inner_run
autoreload.raise_last_exception()
File "/virtualenv/lib/python3.6/site-packages/django/utils/autoreload.py", line 251, in raise_last_exception
six.reraise(*_exception)
File "/virtualenv/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/virtualenv/lib/python3.6/site-packages/django/utils/autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "/virtualenv/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/virtualenv/lib/python3.6/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/virtualenv/lib/python3.6/site-packages/django/apps/config.py", line 94, in create
module = import_module(entry)
File "/virtualenv/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'aldryn_apphooks_config'
有什么想法吗?
当以交互方式启动容器时,我可以重现错误:mzh@ale $ docker run -it --rm divio/base:4.14-py3.6-slim-stretch /bin/bash
root@5d65902b34a4:/app# python
Python 3.6.8 (default, Mar 27 2019, 08:53:45)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import aldryn_apphooks_config
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'aldryn_apphooks_config'