2017-03-23 157 views
0

我試圖建立一個docker-compose棧應該包含內的另一個容器。這是用我所有的項目運行一個開發環境。搬運工,撰寫量沒有出現在容器

所以,問題是應用程序的源卷未出現內置的圖像上。

MacOS Sierra 
Docker version 17.03.0-ce, build 60ccb22 
Boot2Docker-cli version: v1.8.0 

我的目錄樹

/dockers     <======= one directory with all docker files for each project 

    docker-compose.yml  <======= The main image 

    /project1    <======= dockerfile for each project 
    Dockerfile 
    /project2 
    Dockerfile 
    /project3 
    Dockerfile 

/project1    <======= project1 source folder 
    test.txt 
/project2 
/project3 

我的搬運工,compose.yml

project1: 
    build: ./project1 
    volumes: 
    - ../project1/:/src 

我對project1

FROM python:2.7 

RUN mkdir -p /src 

WORKDIR /src 
RUN echo "---------------------" 
RUN ls -la 
RUN echo "---------------------" 

dockerfile所以我嘗試建立了docker-compose文件

$ sudo docker-compose build --no-cache 

然後演示時,我想到test.txt文件

Building express 
ERROR: Cannot locate specified Dockerfile: Dockerfile 
➜ docker git:(master) ✗ sudo docker-compose build --no-cache 
Building project1 
Step 1/7 : FROM python:2.7 
---> ca388cdb5ac1 
Step 2/7 : RUN mkdir -p /src 
---> Running in 393a462f7a44 
---> 4fbeb32d88b3 
Removing intermediate container 393a462f7a44 
Step 3/7 : WORKDIR /src 
---> 03ce193577ab 
Removing intermediate container b1cd746b699a 
Step 4/7 : RUN echo "--------------------------" 
---> Running in 82df8a512c90 
---------------------------- 
---> 6dea58ba5051 
Removing intermediate container 82df8a512c90 
Step 5/7 : RUN ls -la 
---> Running in 905417d0cd19 
total 8 
drwxr-xr-x 2 root root 4096 Mar 23 17:12 .     <====== EMPTY :(
drwxr-xr-x 1 root root 4096 Mar 23 17:12 ..     <====== EMPTY :(
---> 53764caffb1a 
Removing intermediate container 905417d0cd19 
Step 6/7 : RUN echo "-----------------------------" 
---> Running in 110e765d102a 
---------------------------- 
---> b752230fd6dc 
Removing intermediate container 110e765d102a 
Step 7/7 : EXPOSE 3000 
---> Running in 1cfe2e80d282 
---> 5e3e740d5a9a 
Removing intermediate container 1cfe2e80d282 
Successfully built 5e3e740d5a9a 

回答

0

卷是泊塢運行時配置的空文件夾。因爲它們是可配置的,如果你是在構建階段來引用卷,你會基本上可以創建一個潛在uncheckable破依賴。

我敢肯定有更多的技術原因 - 但它確實不應該做的。將所有這些東西移動到運行時設置命令,你應該沒問題。

+0

感謝您的回答。你能解釋一下如何處理你的建議嗎? – anderlaini