我有一个想要在 docker 容器中运行的 koa.js 应用程序。这个 loa 应用程序需要 couchdb 才能运行,我想将它放在同一个容器中。我知道这不是最佳实践,但它确实是我的用户入门的最佳方式。
Dockerfile:
# DOCKER-VERSION 1.2.0
FROM centos:centos6
# Enable EPEL for CouchDB and Node.js
RUN yum -y update; yum clean all
RUN yum -y install epel-release; yum clean all
RUN yum -y install tar
# Install Node.js and CouchDB
RUN yum -y install couchdb; yum clean all
RUN service couchdb start
RUN yum install -y nodejs
RUN yum install -y npm
# Bundle app source
ADD . .
# Install app dependencies
RUN npm install
RUN npm install -g n
RUN n 0.11.12
# Expose port and run
EXPOSE 8080
CMD ["npm", "start"]
效果很好,应用程序启动但无法连接到 couchdb。投入一个
RUN service couchdb start
以 OK 响应,所以它似乎有效,但是
curl -X GET 127.0.0.1:5984
回应
curl: (7) couldn't connect to host
koa.js 应用程序也是如此:
error: error stack=Error: connect ECONNREFUSED
at exports._errnoException (util.js:745:11)
at Object.afterConnect [as oncomplete] (net.js:995:19), code=ECONNREFUSED, errno=ECONNREFUSED, syscall=connect
有人知道我错过了什么或我做错了什么?