I created a Docker image from a Dockerfile to run a sample Meteor application. My Dockerfile is as follows.
FROM node:0.10.30
RUN curl https://install.meteor.com/ | sh
RUN npm install -g meteorite
RUN cd /tmp && npm install libxmljs exec-sync path
RUN mkdir -p /home/app && cp -a /tmp/node_modules /home/app/
ADD src/ /home/app/
WORKDIR /home/app
ENV PORT 3000
EXPOSE 3000
My code uses 3 npm packages libxmljs, exec-sync and path which all got installed successfully. The Meteor application code and .meteor folder are copied to /home/app
inside the docker image. But when I try to run the Meteor application, I get the following error.
sudo docker run -t -i 46630d0dc02e meteor
[[[[[ ~home/app ]]]]]
=> Started proxy.
=> Starting MongoDB... -
/.meteor/tools/cef2bcd356/lib/node_modules/fibers/future.js:206
throw(ex);
^
Error: Couldn't run ps ax: {"killed":false,"code":127,"signal":null}; Command failed: /bin/sh: 1: ps: not found
at Object.Future.wait (/.meteor/tools/cef2bcd356/lib/node_modules/fibers/future.js:326:15)
at findMongoPids (/.meteor/tools/cef2bcd356/tools/run-mongo.js:89:14)
at findMongoAndKillItDead (/.meteor/tools/cef2bcd356/tools/run-mongo.js:119:14)
at launchOneMongoAndWaitForReadyForInitiate (/.meteor/tools/cef2bcd356/tools/run-mongo.js:234:5)
at launchMongo (/.meteor/tools/cef2bcd356/tools/run-mongo.js:496:7)
at _.extend._startOrRestart (/.meteor/tools/cef2bcd356/tools/run-mongo.js:585:19)
at _.extend.start (/.meteor/tools/cef2bcd356/tools/run-mongo.js:551:10)
at _.extend.start (/.meteor/tools/cef2bcd356/tools/run-all.js:131:24)
at Object.exports.run (/.meteor/tools/cef2bcd356/tools/run-all.js:272:10)
at main.registerCommand.name [as func] (/.meteor/tools/cef2bcd356/tools/commands.js:210:17)
at /.meteor/tools/cef2bcd356/tools/main.js:949:23
- - - - -
at /.meteor/tools/cef2bcd356/tools/run-mongo.js:59:22
at ChildProcess.exithandler (child_process.js:651:7)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:755:16)
at Socket.<anonymous> (child_process.js:968:11)
at Socket.emit (events.js:95:17)
at Pipe.close (net.js:465:12)
I would greatly appreciate if anybody could explain the reason for the error and suggest a solution or workaround for running meteor application in docker container.
node
image dosen't have ps
command.
$ docker run -t -i node:0.10.30 bash
root@1d5c5e3ec748:/# ps
bash: ps: command not found
root@f1d530730c37:/# find / -name ps -type f
root@f1d530730c37:/#
Use another base image which have ps command
or install ps
command on your image by adding RUN
directive to your Dockerfile like below.
FROM node:0.10.30
# Install ps command
RUN apt-get update
RUN apt-get install procps
RUN curl https://install.meteor.com/ | sh
RUN npm install -g meteorite
RUN cd /tmp && npm install libxmljs exec-sync path
RUN mkdir -p /home/app && cp -a /tmp/node_modules /home/app/
ADD src/ /home/app/
WORKDIR /home/app
ENV PORT 3000
EXPOSE 3000
I tested it, and it works fine.
$ docker run -t -i nacyot/meteor bash
root@0b56bf009532:/home/app/test# meteor create test
root@0b56bf009532:/home/app/test# cd test
root@0b56bf009532:/home/app/test# meteor
=> App running at: http://localhost:3000/
root@0b56bf009532:/home/app/test# meteor
[[[[[ ~home/app/test ]]]]]
=> Started proxy.
=> Started MongoDB.
=> Started your app.
=> App running at: http://localhost:3000/
Give a try to phusion/passenger-docker. It is advertised to be a ready2use docker image for Meteor apps.