繁体   English   中英

docker-machine容器中缺少本地文件

[英]local files missing from docker-machine container

所以我有一个简单的容器化django项目,另一个容器用于sass css编译。

我使用docker-compose和一个docker-machine,但是当我启动它时,web容器中没有任何我的本地文件(manage.py等),所以它死了一个file not found: manage.pyfile 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-machine时有什么不同之处?

Docker卷将文件从主机挂载到容器中。

因此,在这种情况下,您已将任何主机docker-machine指向的当前目录挂载到容器中。 除非你有一些时髦的虚拟机交叉安装(比如boot2docker),否则这不会与你运行的机器上的目录相匹配。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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