[英]local files missing from docker-machine container
所以我有一個簡單的容器化django項目,另一個容器用於sass css編譯。
我使用docker-compose和一個docker-machine,但是當我啟動它時,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-machine時有什么不同之處?
Docker卷將文件從主機掛載到容器中。
因此,在這種情況下,您已將任何主機docker-machine指向的當前目錄掛載到容器中。 除非你有一些時髦的虛擬機交叉安裝(比如boot2docker),否則這不會與你運行的機器上的目錄相匹配。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.