我的流星应用中出现ECONNREFUSED错误,所以我尝试回到内置示例
$ git clone https://github.com/meteor/todos tst
$ cd tst
$ meteor npm install
$ meteor update
$ meteor update --all-packages
$ meteor npm install --save bcrypt
$ meteor
这项工作,到目前为止一切顺利。好吧,制作一个docker-compose.yml
meteor:
container_name: tst_meteor_1
image: abernix/meteord:node-8-devbuild
ports:
- "3000:80"
links:
- mongo
volumes:
- ../output:/bundle
environment:
- ROOT_URL=http://localhost:3000
- METEOR_ALLOW_SUPERUSER=true
- MONGO_URL=mongodb://localhost:27017/meteor
mongo:
container_name: tst_mongo_1
image: mongo:3.2-jessie
ports:
- "127.0.0.1:27017:27017"
现在构建应用程序并在docker中运行它
$ meteor build ../output --architecture=os.linux.x86_64 --server-only
$ docker-compose --file docker-compose.yml up -d
检查mongo是否正在运行
$ docker logs -f tst_mongo_1
2017-11-26T04:48:28.340+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=012d211f6526
2017-11-26T04:48:28.340+0000 I CONTROL [initandlisten] db version v3.2.17
2017-11-26T04:48:28.340+0000 I CONTROL [initandlisten] git version: 186656d79574f7dfe0831a7e7821292ab380f667
2017-11-26T04:48:28.340+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1t 3 May 2016
2017-11-26T04:48:28.340+0000 I CONTROL [initandlisten] allocator: tcmalloc
2017-11-26T04:48:28.340+0000 I CONTROL [initandlisten] modules: none
2017-11-26T04:48:28.340+0000 I CONTROL [initandlisten] build environment:
2017-11-26T04:48:28.340+0000 I CONTROL [initandlisten] distmod: debian81
2017-11-26T04:48:28.340+0000 I CONTROL [initandlisten] distarch: x86_64
2017-11-26T04:48:28.340+0000 I CONTROL [initandlisten] target_arch: x86_64
2017-11-26T04:48:28.340+0000 I CONTROL [initandlisten] options: {}
2017-11-26T04:48:28.343+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1G,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),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2017-11-26T04:48:28.380+0000 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2017-11-26T04:48:28.380+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2017-11-26T04:48:28.381+0000 I NETWORK [initandlisten] waiting for connections on port 27017
是的,请检查meteor是否正在运行
$ docker logs -f tst_meteor_1
> meteor-dev-bundle@0.0.0 install /bundle/bundle/programs/server
> node npm-rebuild.js
> bcrypt@1.0.3 install /bundle/bundle/programs/server/npm/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build
[bcrypt] Success: "/bundle/bundle/programs/server/npm/node_modules/bcrypt/lib/binding/bcrypt_lib.node" is installed via remote
> fibers@2.0.0 install /bundle/bundle/programs/server/npm/node_modules/fibers
> node build.js || nodejs build.js
`linux-x64-57` exists; testing
Binary is fine; exiting
abbrev@1.1.1 /bundle/bundle/programs/server/npm/node_modules/abbrev
... 202 lines of node_modules
indexof@0.0.1 /bundle/bundle/programs/server/npm/node_modules/meteor-node-stubs/node_modules/indexof
{
"meteor-dev-bundle": "0.0.0",
"npm": "5.5.1",
"ares": "1.10.1-DEV",
"cldr": "31.0.1",
"http_parser": "2.7.0",
"icu": "59.1",
"modules": "57",
"nghttp2": "1.25.0",
"node": "8.9.1",
"openssl": "1.0.2m",
"tz": "2017b",
"unicode": "9.0",
"uv": "1.15.0",
"v8": "6.1.534.47",
"zlib": "1.2.11"
}
npm WARN meteor-dev-bundle@0.0.0 No description
npm WARN meteor-dev-bundle@0.0.0 No repository field.
npm WARN meteor-dev-bundle@0.0.0 No license field.
up to date in 9.48s
=> Starting meteor app on port:80
/bundle/bundle/programs/server/node_modules/fibers/future.js:313
throw(ex);
^
MongoError: failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]
at Pool.<anonymous> (/bundle/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/topologies/server.js:336:35)
at emitOne (events.js:116:13)
at Pool.emit (events.js:211:7)
at Connection.<anonymous> (/bundle/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/connection/pool.js:280:12)
at Object.onceWrapper (events.js:317:30)
at emitTwo (events.js:126:13)
at Connection.emit (events.js:214:7)
at Socket.<anonymous> (/bundle/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/connection/connection.js:187:49)
at Object.onceWrapper (events.js:315:30)
at emitOne (events.js:116:13)
我收到了ECONNREFUSED错误
我只是猜测这是一个泊坞问题。我过去运行的是docker-machine,但最近升级到了docker mac(很多东西都破了)。
知道如何解决这个问题吗?
我尝试过的其他一些事情,
尝试创建共享网络
version: "3.3"
services:
meteor:
container_name: tst_meteor_1
image: abernix/meteord:node-8-devbuild
ports:
- "3000:80"
links:
- mongo
networks:
- tst
volumes:
- ../output:/bundle
environment:
- ROOT_URL=http://localhost:3000
- METEOR_ALLOW_SUPERUSER=true
- MONGO_URL=mongodb://localhost:27017/meteor
mongo:
container_name: tst_mongo_1
image: mongo:3.2-jessie
networks:
- tst
expose:
- "27017"
ports:
- "127.0.0.1:27017:27017"
networks:
tst:
driver: bridge
答案 0 :(得分:1)
显然问题是docker现在需要mongo url的容器名称
是:
environment:
- ROOT_URL=http://localhost:3000
- METEOR_ALLOW_SUPERUSER=true
- MONGO_URL=mongodb://localhost:27017/meteor
现在:
environment:
- ROOT_URL=http://localhost:3000
- METEOR_ALLOW_SUPERUSER=true
- MONGO_URL=mongodb://mongo:27017/meteor
,其中
- MONGO_URL=mongodb://<name-of-container>:27017/meteor