docker-machine容器中缺less本地文件
所以我有一个简单的集装箱django项目,另一个容器为CSS CSS编译。
我使用docker-compose和docker-machine,但是当我启动web容器时,web容器没有任何我的本地文件(manage.py等),所以它死了, file not found: 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-machine
的问题,我试图遵循简单的django教程 ,我认为本地文件共享工作方式不同。
使用docker机器时有什么不同的作用?
Docker卷将主机中的文件挂载到容器中。
因此,在这种情况下,您已经将docker-machine指向的任何主机的当前目录挂载到容器中。 除非你有一些虚拟的VM交叉安装(比如boot2docker),否则这将不会匹配你正在运行的机器上的目录。