我尝试将Fig + Django教程中的项目布局更改为:
.
├── docker
│ └── django
│ ├── Dockerfile
│ └── requirements.txt
├── fig.yml
└── project
├── figexample
│ ├── __init__.py
│ ├── __init__.pyc
│ ├── settings.py
│ ├── settings.pyc
│ ├── urls.py
│ ├── urls.pyc
│ ├── wsgi.py
│ └── wsgi.pyc
└── manage.py
我的fig.yml看起来像:
db:
image: postgres
web:
build: ./docker/django
volumes:
- "project/:/code"
ports:
- "8000:8000"
links:
- db
command: "ls -a ."
但由于某些原因而不是project
目录,它会挂载当前目录。
在这种情况下fig logs
的结果将是:
#$ fig logs
Attaching to figdjango_web_1, figdjango_db_1
db_1 | LOG: database system was shut down at 2014-11-05 15:15:41 UTC
db_1 | LOG: database system is ready to accept connections
db_1 | LOG: autovacuum launcher started
web_1 | .
web_1 | ..
web_1 | .fig.yml.swp
web_1 | docker
web_1 | fig.yml
web_1 | project
figdjango_web_1 exited with code 0
我的Dockerfile:
FROM python:2.7
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
ADD requirements.txt /code/
RUN pip install -r requirements.txt
我做错了什么?我如何挂载/项目到/代码?
答案 0 :(得分:1)
您在github上链接的示例与您在问题中描述的示例略有不同。
在github示例中,替换
command: python /project/manage.py runserver 0.0.0.0:8000
带
command: python /code/manage.py runserver 0.0.0.0:8000`
它有效。