【发布时间】:2015-10-12 13:16:01
【问题描述】:
所以我有一个简单的容器化 django 项目,还有另一个用于 sass css 编译的容器。
我将 docker-compose 与 docker-machine 一起使用,但是当我启动它时,Web 容器中没有我的任何本地文件(manage.py 等),因此它因 file not found: manage.py 错误而死.
让我解释一下:
docker-compose.yml
web:
build: .
volumes:
- .:/app
ports:
- "8001:5000"
sass:
image: ubuntudesign/sass
command: sass --debug-info --watch /app/static/css -E "UTF-8"
volumes:
- .:/app
Dockerfile
FROM ubuntu:14.04
# Install apt dependencies
RUN apt-get update && apt-get install -y python-dev python-pip git bzr libpq-dev pkg-config
FROM ubuntu:14.04
# Install apt dependencies
RUN apt-get update && apt-get install -y python-dev python-pip git bzr libpq-dev pkg-config
# Pip requirements files
COPY requirements /requirements
# Install pip requirements
RUN pip install -r /requirements/dev.txt
COPY . /app
WORKDIR /app
CMD ["python", "manage.py", "runserver", "0.0.0.0:5000"]
以及本地目录下的标准django项目:
$ ls
docker-compose.yml Dockerfile manage.py README.md static templates webapp
这是我能做到的孤立错误:
$ docker-compose run web python
can't open file 'manage.py': [Errno 2] No such file or directory
这是真的:
$ docker-compose run web ls
static
我认为这是使用远程docker-machines 的问题,我尝试关注simple django tutorial,但我认为本地文件共享的工作方式不同。
使用 docker-machine 有什么不同?
【问题讨论】:
-
您介意对“最终结果”Dockerfile 和 docker-compose.yml 文件进行编辑吗?
-
我不再有那个配置了,抱歉,但是很简单:只在一个单元上进行复制(我使用了 web 单元),然后所有其他单元执行 volume_from: web
标签: django postgresql docker docker-compose docker-machine