Docker没有创build我的/ app目录

我有一个小的docker-compose.yml文件来build立一个小的Flask项目,并拉起一个MongoDB容器。 当我尝试docker-compose up的东西时,我的问题发生,后端无法开始输出,说明它找不到我的app.py文件。 输出中不会出现其他错误。

这是我的项目目录:

 . ├── backend │  ├── app.py │  ├── Dockerfile │  ├── models.py │  └── requirements.txt └── docker-compose.yml 

这里是Dockerfile:

 FROM python:3.6.3 RUN mkdir /app COPY . /app EXPOSE 5000 WORKDIR /app RUN pip install -r requirements.txt CMD ["python", "app.py"] 

以下是docker-compose.yml文件:

 version: '2' services: db: image: mongo:3.6 backend: build: ./backend depends_on: - db ports: - "5000:5000" volumes: - ./backend:/app 

这里是输出:

 Creating network "abc123_default" with the default driver Building backend Step 1/7 : FROM python:3.6.3 ---> 79e1dc9af1c1 Step 2/7 : RUN mkdir /app ---> Running in 0327c1c8071a ---> 2b51a33f4b54 Removing intermediate container 0327c1c8071a Step 3/7 : COPY . /app ---> 0aa1b565de3a Step 4/7 : EXPOSE 5000 ---> Running in 469ca93770e0 ---> 8fbedb3aeadc Removing intermediate container 469ca93770e0 Step 5/7 : WORKDIR /app ---> c0655741ad99 Removing intermediate container 6b5d02208a10 Step 6/7 : RUN pip install -r requirements.txt ---> Running in 745778ca1f30 ...snip... Installing collected packages: six, python-dateutil, aniso8601, click, Werkzeug, itsdangerous, MarkupSafe, Jinja2, Flask, Flask-API, pymongo, Flask-PyMongo, pytz, Flask-RESTful Successfully installed Flask-0.12.2 Flask-API-1.0 Flask-PyMongo-0.5.1 Flask-RESTful-0.3.6 Jinja2-2.10 MarkupSafe-1.0 Werkzeug-0.12.2 aniso8601-1.3.0 click-6.7 itsdangerous-0.24 pymongo-3.5.1 python-dateutil-2.6.1 pytz-2017.3 six-1.11.0 ---> c3a9db2bd541 Removing intermediate container 745778ca1f30 Step 7/7 : CMD python app.py ---> Running in 5bd08e5ecb94 ---> 06edb3e6899d Removing intermediate container 5bd08e5ecb94 Successfully built 06edb3e6899d Successfully tagged britecore_backend:latest Creating britecore_db_1 Creating britecore_backend_1 Attaching to britecore_db_1, britecore_backend_1 db_1 | 2017-12-04T18:32:04.301+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=5d77f1ab7ac4 db_1 | 2017-12-04T18:32:04.301+0000 I CONTROL [initandlisten] db version v3.6.0-rc7 db_1 | 2017-12-04T18:32:04.301+0000 I CONTROL [initandlisten] git version: 71b56638c7ece7be000da5b96d5f3c77ace85847 db_1 | 2017-12-04T18:32:04.302+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1t 3 May 2016 backend_1 | python: can't open file 'app.py': [Errno 2] No such file or directory db_1 | 2017-12-04T18:32:04.302+0000 I CONTROL [initandlisten] allocator: tcmalloc db_1 | 2017-12-04T18:32:04.302+0000 I CONTROL [initandlisten] modules: none db_1 | 2017-12-04T18:32:04.302+0000 I CONTROL [initandlisten] build environment: db_1 | 2017-12-04T18:32:04.302+0000 I CONTROL [initandlisten] distmod: debian81 db_1 | 2017-12-04T18:32:04.302+0000 I CONTROL [initandlisten] distarch: x86_64 db_1 | 2017-12-04T18:32:04.302+0000 I CONTROL [initandlisten] target_arch: x86_65 db_1 | 2017-12-04T18:32:04.302+0000 I CONTROL [initandlisten] options: { net: { bindIpAll: true } } db_1 | 2017-12-04T18:32:04.302+0000 I STORAGE [initandlisten] db_1 | 2017-12-04T18:32:04.302+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine db_1 | 2017-12-04T18:32:04.302+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem db_1 | 2017-12-04T18:32:04.302+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=478M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress), db_1 | 2017-12-04T18:32:06.272+0000 I CONTROL [initandlisten] db_1 | 2017-12-04T18:32:06.272+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database. db_1 | 2017-12-04T18:32:06.272+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted. db_1 | 2017-12-04T18:32:06.272+0000 I CONTROL [initandlisten] db_1 | 2017-12-04T18:32:06.272+0000 I STORAGE [initandlisten] createCollection: admin.system.version with provided UUID: 38de0221-c471-4958-9ac2-7af5b8600589 db_1 | 2017-12-04T18:32:06.845+0000 I COMMAND [initandlisten] setting featureCompatibilityVersion to 3.6 db_1 | 2017-12-04T18:32:06.849+0000 I STORAGE [initandlisten] createCollection: local.startup_log with generated UUID: cab2d33a-0659-4af7-96cf-4f2cbc195108 db_1 | 2017-12-04T18:32:07.277+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data' db_1 | 2017-12-04T18:32:07.278+0000 I NETWORK [initandlisten] waiting for connections on port 27017 britecore_backend_1 exited with code 2 db_1 | 2017-12-04T18:37:07.278+0000 I STORAGE [thread1] createCollection: config.system.sessions with generated UUID: 61b2936d-b932-4918-aadc-4e5fdd3066ac db_1 | 2017-12-04T18:37:07.698+0000 I INDEX [thread1] build index on: config.system.sessions properties: { v: 2, key: { lastUse: 1 }, name: "lsidTTLIndex", ns: "config.system.sessions", expireAfterSeconds: 1800 } db_1 | 2017-12-04T18:37:07.698+0000 I INDEX [thread1] building index using bulk method; build may temporarily use up to 500 megabytes of RAM db_1 | 2017-12-04T18:37:07.700+0000 I INDEX [thread1] build index done. scanned 0 total records. 0 secs db_1 | 2017-12-04T18:37:07.700+0000 I COMMAND [thread1] command config.$cmd command: createIndexes { createIndexes: "system.sessions", indexes: [ { key: { lastUse: 1 }, name: "lsidTTLIndex", expireAfterSeconds: 1800 } ], $db: "config" } numYields:0 reslen:98 locks:{ Global: { acquireCount: { r: 1, w: 1 } }, Database: { acquireCount: { W: 1 } }, Collection: { acquireCount: { w: 1 } } } protocol:op_msg 421ms_wheel for MarkupSafe: finished with status 'done' Stored in directory: /root/.cache/pip/wheels/88/a7/30/e39a54a87bcbe25308fa3ca64e8ddc75d9b3e5afa21ee32d57 Successfully built aniso8601 Flask-API itsdangerous MarkupSafe Installing collected packages: six, python-dateutil, aniso8601, click, Werkzeug, itsdangerous, MarkupSafe, Jinja2, Flask, Flask-API, pymongo, Flask-PyMongo, pytz, Flask-RESTful Successfully installed Flask-0.12.2 Flask-API-1.0 Flask-PyMongo-0.5.1 Flask-RESTful-0.3.6 Jinja2-2.10 MarkupSafe-1.0 Werkzeug-0.12.2 aniso8601-1.3.0 click-6.7 itsdangerous-0.24 pymongo-3.5.1 python-dateutil-2.6.1 pytz-2017.3 six-1.11.0 ---> c3a9db2bd541 Removing intermediate container 745778ca1f30 Step 7/7 : CMD python app.py ---> Running in 5bd08e5ecb94 ---> 06edb3e6899d Removing intermediate container 5bd08e5ecb94 Successfully built 06edb3e6899d Successfully tagged abc123_backend:latest Creating abc123_db_1 Creating abc123_backend_1 Attaching to abc123_db_1, abc123_backend_1 db_1 | 2017-12-04T18:32:04.301+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=5d77f1ab7ac4 db_1 | 2017-12-04T18:32:04.301+0000 I CONTROL [initandlisten] db version v3.6.0-rc7 db_1 | 2017-12-04T18:32:04.301+0000 I CONTROL [initandlisten] git version: 71b56638c7ece7be000da5b96d5f3c77ace85847 db_1 | 2017-12-04T18:32:04.302+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1t 3 May 2016 backend_1 | python: can't open file 'app.py': [Errno 2] No such file or directory ...snip... abc124_backend_1 exited with code 2 

我认为我的问题可能与卷有关,但我不完全确定这是怎么回事。 任何帮助,将不胜感激。