apostrophecms / apostrophe

A full-featured, open-source content management framework built with Node.js that empowers organizations by combining in-context editing and headless architecture in a full-stack JS environment.
https://apostrophecms.com
MIT License
4.36k stars 591 forks source link

Running in docker, Mongo connection failing #1987

Closed mastermsd closed 5 years ago

mastermsd commented 5 years ago

Apostrophe v2.93.0 Node v12.6.0 MacOS 10.13.6 Docker 19.03.1

Hi,

I'm trying to run Apostrophe with Docker on my local machine. I followed this doc: https://docs.apostrophecms.org/apostrophe/tutorials/howtos/docker

But when running docker-compose up I get the following:

Starting mastermsd-cms-apostrophe_mongo_1 ... done
Starting mastermsd-cms-apostrophe_aposcms_1 ... done
Attaching to mastermsd-cms-apostrophe_mongo_1, mastermsd-cms-apostrophe_aposcms_1
mongo_1    | 2019-08-02T14:54:36.679+0000 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
mongo_1    | 2019-08-02T14:54:36.682+0000 I CONTROL  [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=61086b3a3814
mongo_1    | 2019-08-02T14:54:36.682+0000 I CONTROL  [initandlisten] db version v4.0.11
mongo_1    | 2019-08-02T14:54:36.682+0000 I CONTROL  [initandlisten] git version: 417d1a712e9f040d54beca8e4943edce218e9a8c
mongo_1    | 2019-08-02T14:54:36.682+0000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016
mongo_1    | 2019-08-02T14:54:36.682+0000 I CONTROL  [initandlisten] allocator: tcmalloc
mongo_1    | 2019-08-02T14:54:36.682+0000 I CONTROL  [initandlisten] modules: none
mongo_1    | 2019-08-02T14:54:36.682+0000 I CONTROL  [initandlisten] build environment:
mongo_1    | 2019-08-02T14:54:36.682+0000 I CONTROL  [initandlisten]     distmod: ubuntu1604
mongo_1    | 2019-08-02T14:54:36.682+0000 I CONTROL  [initandlisten]     distarch: x86_64
mongo_1    | 2019-08-02T14:54:36.682+0000 I CONTROL  [initandlisten]     target_arch: x86_64
mongo_1    | 2019-08-02T14:54:36.682+0000 I CONTROL  [initandlisten] options: { net: { bindIpAll: true } }
mongo_1    | 2019-08-02T14:54:36.682+0000 I STORAGE  [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
mongo_1    | 2019-08-02T14:54:36.682+0000 I STORAGE  [initandlisten] 
mongo_1    | 2019-08-02T14:54:36.682+0000 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
mongo_1    | 2019-08-02T14:54:36.682+0000 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
mongo_1    | 2019-08-02T14:54:36.682+0000 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=487M,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),
mongo_1    | 2019-08-02T14:54:37.218+0000 I STORAGE  [initandlisten] WiredTiger message [1564757677:218713][1:0x7fadec9daa80], txn-recover: Main recovery loop: starting at 7/5248 to 8/256
mongo_1    | 2019-08-02T14:54:37.302+0000 I STORAGE  [initandlisten] WiredTiger message [1564757677:302575][1:0x7fadec9daa80], txn-recover: Recovering log 7 through 8
mongo_1    | 2019-08-02T14:54:37.363+0000 I STORAGE  [initandlisten] WiredTiger message [1564757677:363373][1:0x7fadec9daa80], txn-recover: Recovering log 8 through 8
mongo_1    | 2019-08-02T14:54:37.405+0000 I STORAGE  [initandlisten] WiredTiger message [1564757677:405643][1:0x7fadec9daa80], txn-recover: Set global recovery timestamp: 0
mongo_1    | 2019-08-02T14:54:37.414+0000 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
aposcms_1  | 
aposcms_1  | > mastermsd-cms-apostrophe@2.0.0 start /app
aposcms_1  | > node app.js
aposcms_1  | 
mongo_1    | 2019-08-02T14:54:37.418+0000 I CONTROL  [initandlisten] 
mongo_1    | 2019-08-02T14:54:37.418+0000 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
mongo_1    | 2019-08-02T14:54:37.418+0000 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
mongo_1    | 2019-08-02T14:54:37.418+0000 I CONTROL  [initandlisten] 
mongo_1    | 2019-08-02T14:54:37.426+0000 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
mongo_1    | 2019-08-02T14:54:37.428+0000 I NETWORK  [initandlisten] waiting for connections on port 27017
aposcms_1  | ERROR: There was an issue connecting to the database. Is it running?
aposcms_1  | /app/node_modules/apostrophe/index.js:78
aposcms_1  |         throw err;
aposcms_1  |         ^
aposcms_1  | 
aposcms_1  | Error: slash in host identifier
aposcms_1  |     at parseConnectionString (/app/node_modules/mongodb/lib/url_parser.js:202:15)
aposcms_1  |     at parseHandler (/app/node_modules/mongodb/lib/url_parser.js:113:14)
aposcms_1  |     at module.exports (/app/node_modules/mongodb/lib/url_parser.js:98:5)
aposcms_1  |     at connect (/app/node_modules/mongodb/lib/mongo_client.js:485:3)
aposcms_1  |     at Function.MongoClient.connect (/app/node_modules/mongodb/lib/mongo_client.js:250:3)
aposcms_1  |     at self.connectToMongo (/app/node_modules/apostrophe/lib/modules/apostrophe-db/index.js:135:32)
aposcms_1  |     at /app/node_modules/async/lib/async.js:718:13
aposcms_1  |     at iterate (/app/node_modules/async/lib/async.js:262:13)
aposcms_1  |     at async.forEachOfSeries.async.eachOfSeries (/app/node_modules/async/lib/async.js:281:9)
aposcms_1  |     at _parallel (/app/node_modules/async/lib/async.js:717:9)
aposcms_1  |     at Object.async.series (/app/node_modules/async/lib/async.js:739:9)
aposcms_1  |     at afterConstruct (/app/node_modules/apostrophe/lib/modules/apostrophe-db/index.js:50:18)
aposcms_1  |     at /app/node_modules/moog/index.js:312:22
aposcms_1  |     at /app/node_modules/async/lib/async.js:181:20
aposcms_1  |     at iterate (/app/node_modules/async/lib/async.js:262:13)
aposcms_1  |     at Immediate.<anonymous> (/app/node_modules/async/lib/async.js:274:29)
aposcms_1  | npm ERR! code ELIFECYCLE
aposcms_1  | npm ERR! errno 1
aposcms_1  | npm ERR! mastermsd-cms-apostrophe@2.0.0 start: `node app.js`
aposcms_1  | npm ERR! Exit status 1
aposcms_1  | npm ERR! 
aposcms_1  | npm ERR! Failed at the mastermsd-cms-apostrophe@2.0.0 start script.
aposcms_1  | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
aposcms_1  | 

in app.js I have the following:

'apostrophe-db': {
  uri: 'mongodb://' + process.env.MONGODB_PORT_27017_TCP_ADDR + ':' + process.env.MONGODB_PORT_27017_TCP_PORT
},

which variables are defined in docker-compose.yml:

MONGODB_PORT_27017_TCP_ADDR: 'mongodb://mongo'
MONGODB_PORT_27017_TCP_PORT: '27017'

I try to connect with MongoDb with MongoDB Compass and I do get a successful connection on 127.0.0.1:27017 or localhost:27017.

What am I doing wrong? Please help!

vincentrohde commented 3 years ago

@mastermsd did you find a solution to your issue?