将docker-compose文件添加到后端具有MongoDB的flask应用程序中
获得以下错误
尝试使用mongodb数据库对烧瓶进行烧瓶化以创建烧瓶应用程序
如图所示尝试docker-compose文件并得到此错误
Starting efd79ac4bc91_rb_rb_1 ... done
Starting rb_web_1 ... done
Attaching to efd79ac4bc91_rb_rb_1, rb_web_1
web_1 | python3: can't open file 'python3': [Errno 2] No such file or directory
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:23:59.860+0000 W - [initandlisten] Detected unclean shutdown - /data/db/mongod.lock is not empty.
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:23:59.910+0000 I JOURNAL [initandlisten] journal dir=/data/db/journal
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:23:59.910+0000 I JOURNAL [initandlisten] recover begin
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:23:59.910+0000 I JOURNAL [initandlisten] info no lsn file in journal/ directory
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:23:59.910+0000 I JOURNAL [initandlisten] recover lsn: 0
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:23:59.910+0000 I JOURNAL [initandlisten] recover /data/db/journal/j._0
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:23:59.949+0000 I JOURNAL [initandlisten] recover cleaning up
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:23:59.949+0000 I JOURNAL [initandlisten] removeJournalFiles
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:24:00.086+0000 I JOURNAL [initandlisten] recover done
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:24:00.086+0000 I JOURNAL [initandlisten] preallocating a journal file /data/db/journal/prealloc.0
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:24:03.033+0000 I - [initandlisten] File Preallocator Progress: 293601280/1073741824 27%
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:24:06.283+0000 I - [initandlisten] File Preallocator Progress: 419430400/1073741824 39%
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:24:09.021+0000 I - [initandlisten] File Preallocator Progress: 513802240/1073741824 47%
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:24:12.501+0000 I - [initandlisten] File Preallocator Progress: 671088640/1073741824 62%
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:24:15.078+0000 I - [initandlisten] File Preallocator Progress: 828375040/1073741824 77%
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:24:18.150+0000 I - [initandlisten] File Preallocator Progress: 1006632960/1073741824 93%
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:24:22.636+0000 I JOURNAL [durability] Durability thread started
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:24:22.637+0000 I JOURNAL [journal writer] Journal writer thread started
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:24:22.837+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=efd79ac4bc91
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:24:22.868+0000 I CONTROL [initandlisten] db version v3.0.2
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:24:22.868+0000 I CONTROL [initandlisten] git version: 6201872043ecbbc0a4cc169b5482dcf385fc464f
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:24:22.868+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1e 11 Feb 2013
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:24:22.868+0000 I CONTROL [initandlisten] build info: Linux ip-10-171-120-232 3.2.0-4-amd64 #1 SMP Debian 3.2.46-1 x86_64 BOOST_LIB_VERSION=1_49
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:24:22.868+0000 I CONTROL [initandlisten] allocator: tcmalloc
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:24:22.868+0000 I CONTROL [initandlisten] options: {}
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:24:23.848+0000 I - [initandlisten] Invariant failure 1 == version src/mongo/db/storage/mmap_v1/btree/btree_interface.cpp 284
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:24:23.958+0000 I CONTROL [initandlisten]
efd79ac4bc91_rb_rb_1 | 0xf6b4b9 0xf0bcb1 0xef0762 0xd074fb 0xd4c3c5 0x940e44 0x94440d 0x92f81d 0x939e47 0x93bc83 0x93e900 0x824311 0x7f0794 0x7f285689eead 0x821909
efd79ac4bc91_rb_rb_1 | ----- BEGIN BACKTRACE -----
efd79ac4bc91_rb_rb_1 | {"backtrace":[{"b":"400000","o":"B6B4B9"},{"b":"400000","o":"B0BCB1"},{"b":"400000","o":"AF0762"},{"b":"400000","o":"9074FB"},{"b":"400000","o":"94C3C5"},{"b":"400000","o":"540E44"},{"b":"400000","o":"54440D"},{"b":"400000","o":"52F81D"},{"b":"400000","o":"539E47"},{"b":"400000","o":"53BC83"},{"b":"400000","o":"53E900"},{"b":"400000","o":"424311"},{"b":"400000","o":"3F0794"},{"b":"7F2856880000","o":"1EEAD"},{"b":"400000","o":"421909"}],"processInfo":{ "mongodbVersion" : "3.0.2", "gitVersion" : "6201872043ecbbc0a4cc169b5482dcf385fc464f", "uname" : { "sysname" : "Linux", "release" : "4.15.0-51-generic", "version" : "#55~16.04.1-Ubuntu SMP Thu May 16 09:24:37 UTC 2019", "machine" : "x86_64" }, "somap" : [ { "elfType" : 2, "b" : "400000", "buildId" : "FE06CE34D0A8EA7A70E5E8682BFCDB31D065F341" }, { "b" : "7FFD55DAF000", "elfType" : 3, "buildId" : "19BC8D0DBED28C6A57752B2E69A100DC4D5BF738" }, { "b" : "7F2857E0E000", "path" : "/lib/x86_64-linux-gnu/libpthread.so.0", "elfType" : 3, "buildId" : "FEF281218797AD6AE726DD5FCEDECADD9E9F51DC" }, { "b" : "7F2857BAE000", "path" : "/usr/lib/x86_64-linux-gnu/libssl.so.1.0.0", "elfType" : 3, "buildId" : "AEE5F3A05E87AFA440FCF6352C568A0F08584119" }, { "b" : "7F28577B6000", "path" : "/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0", "elfType" : 3, "buildId" : "37084B8E55653C947BA6295814D850D6AA0C561D" }, { "b" : "7F28575AE000", "path" : "/lib/x86_64-linux-gnu/librt.so.1", "elfType" : 3, "buildId" : "F58D5DE3E7A2989E915422BA4203FE53DBA449A0" }, { "b" : "7F28573AA000", "path" : "/lib/x86_64-linux-gnu/libdl.so.2", "elfType" : 3, "buildId" : "5D1CA3A3D93ED5B6C6462FFA03E787FDBE4013A3" }, { "b" : "7F28570A3000", "path" : "/usr/lib/x86_64-linux-gnu/libstdc++.so.6", "elfType" : 3, "buildId" : "8711429397A5AF8B6269B867D830EDF6E0225B8D" }, { "b" : "7F2856E21000", "path" : "/lib/x86_64-linux-gnu/libm.so.6", "elfType" : 3, "buildId" : "7F58D6664571941C86B2D969701A572AD4D7BF1D" }, { "b" : "7F2856C0B000", "path" : "/lib/x86_64-linux-gnu/libgcc_s.so.1", "elfType" : 3, "buildId" : "F980B1188708F8D8B5C35D185444AF4CB939AA1E" }, { "b" : "7F2856880000", "path" : "/lib/x86_64-linux-gnu/libc.so.6", "elfType" : 3, "buildId" : "A745EBA2C16BA80AE1EF1A7A7B70740C2CF1B363" }, { "b" : "7F285802A000", "path" : "/lib64/ld-linux-x86-64.so.2", "elfType" : 3, "buildId" : "9B23F2A44CC8CA6175CBD8D64584B1C7EA5FD18C" }, { "b" : "7F2856669000", "path" : "/lib/x86_64-linux-gnu/libz.so.1", "elfType" : 3, "buildId" : "1EFEB71FD4999C2307570D673A724EA4E1D85267" } ] }}
efd79ac4bc91_rb_rb_1 | mongod(_ZN5mongo15printStackTraceERSo+0x29) [0xf6b4b9]
efd79ac4bc91_rb_rb_1 | mongod(_ZN5mongo10logContextEPKc+0xE1) [0xf0bcb1]
efd79ac4bc91_rb_rb_1 | mongod(_ZN5mongo15invariantFailedEPKcS1_j+0xB2) [0xef0762]
efd79ac4bc91_rb_rb_1 | mongod(_ZN5mongo18getMMAPV1InterfaceEPNS_11HeadManagerEPNS_11RecordStoreEPNS_19SavedCursorRegistryERKNS_8OrderingERKSsi+0x1CB) [0xd074fb]
efd79ac4bc91_rb_rb_1 | mongod(_ZN5mongo26MMAPV1DatabaseCatalogEntry8getIndexEPNS_16OperationContextEPKNS_22CollectionCatalogEntryEPNS_17IndexCatalogEntryE+0x75) [0xd4c3c5]
efd79ac4bc91_rb_rb_1 | mongod(_ZN5mongo12IndexCatalog24_setupInMemoryStructuresEPNS_16OperationContextEPNS_15IndexDescriptorEb+0x94) [0x940e44]
efd79ac4bc91_rb_rb_1 | mongod(_ZN5mongo12IndexCatalog4initEPNS_16OperationContextE+0x24D) [0x94440d]
efd79ac4bc91_rb_rb_1 | mongod(_ZN5mongo10CollectionC2EPNS_16OperationContextERKNS_10StringDataEPNS_22CollectionCatalogEntryEPNS_11RecordStoreEPNS_20DatabaseCatalogEntryE+0xFD) [0x92f81d]
efd79ac4bc91_rb_rb_1 | mongod(_ZN5mongo8Database30_getOrCreateCollectionInstanceEPNS_16OperationContextERKNS_10StringDataE+0x87) [0x939e47]
efd79ac4bc91_rb_rb_1 | mongod(_ZN5mongo8DatabaseC1EPNS_16OperationContextERKNS_10StringDataEPNS_20DatabaseCatalogEntryE+0x1E3) [0x93bc83]
efd79ac4bc91_rb_rb_1 | mongod(_ZN5mongo14DatabaseHolder6openDbEPNS_16OperationContextERKNS_10StringDataEPb+0x150) [0x93e900]
efd79ac4bc91_rb_rb_1 | mongod(_ZN5mongo13initAndListenEi+0xC01) [0x824311]
efd79ac4bc91_rb_rb_1 | mongod(main+0x134) [0x7f0794]
efd79ac4bc91_rb_rb_1 | libc.so.6(__libc_start_main+0xFD) [0x7f285689eead]
efd79ac4bc91_rb_rb_1 | mongod(+0x421909) [0x821909]
efd79ac4bc91_rb_rb_1 | ----- END BACKTRACE -----
efd79ac4bc91_rb_rb_1 | 2019-06-12T06:24:23.958+0000 I - [initandlisten]
efd79ac4bc91_rb_rb_1 |
efd79ac4bc91_rb_rb_1 | ***aborting after invariant() failure
efd79ac4bc91_rb_rb_1 |
efd79ac4bc91_rb_rb_1 |
rb_web_1 exited with code 2
efd79ac4bc91_rb_rb_1 exited with code 14
docker-compose文件如下所示
web:
build: .
command: python3 -u app.py
ports:
- "5000:5000"
volumes:
- .:/app
links:
- rb
rb:
image: mongo:3.0.2
添加的mongo文件是这样的
client = pymongo.MongoClient(os.environ['DB_PORT_27017_TCP_ADDR'],27017)
db = client['sb']
rb = db.rb
dockerfile为
FROM python:3.5
RUN apt-get install -y python3-dev python3-pip
WORKDIR /app
COPY . /app
RUN pip3 install -r requirements.txt
EXPOSE 5000
ENTRYPOINT ["python3"]
CMD ["app.py"]
-需要用于修复上述错误的应用程序的正确构建
答案 0 :(得分:0)
Remove the ENTRYPOINT and CMD from Dockerfile and try again.
在docker compose文件中,命令 python3 -u app.py 通过python3的入口点运行。 因此,该命令实际上成为 python3 python3 -u app.py 。如果将python3包含在命令中,则无需提供python3作为入口点。
或者保留Entrypoint和cmd并在docker compose文件中将命令更改为 -u app.py
答案 1 :(得分:0)
在app.py
文件中,将'DB_PORT_27017_TCP_ADDR'
更改为172.17.0.1
其容器的IP地址网关。
请确保Remove the ENTRYPOINT and CMD from Dockerfile and try again.