docker - Node.js Koa app and CouchDB in single container -


i have koa.js app want run in docker container. loa app requires couchdb run, want ship in same container. know not best practise indeed best way users started.

dockerfile:

# docker-version 1.2.0 centos:centos6  # enable epel couchdb , node.js run yum -y update; yum clean run yum -y install epel-release; yum clean run yum -y install tar  # install node.js , couchdb run yum -y install couchdb; yum clean 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 , run expose 8080 cmd ["npm", "start"] 

which works fine, app gets launched can't connect couchdb. throwing in a

run service couchdb start 

response ok, seems work, but

curl -x 127.0.0.1:5984 

response with

curl: (7) couldn't connect host 

same koa.js app:

error: error stack=error: connect econnrefused @ exports._errnoexception (util.js:745:11) @ object.afterconnect [as oncomplete] (net.js:995:19), code=econnrefused, errno=econnrefused, syscall=connect 

someone knows missing or doing wrong?

the command run when start image in cmd line. every line before creates read only, non-running image. thus, line run service couchdb start start service instant, until marked successful, docker stop image, save it, , move on next line. "running" state of service doesn't persist.

it common misconception, , 1 fell when started.

the 3 options, top being fastest yet hacky, , last being work proper:

  1. put service couchdb start && npm start cmd line.
  2. create startup.sh script, "running" need in there, , call cmd line
  3. use service designed stuff you, supervisord recommended.

this common issue, if have read through google results searching "start service in docker" you'll see more information around subject.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -