我从Dockerfile创建了一个Docker镜像来运行示例Meteor应用程序。我的Dockerfile如下。
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
我的代码使用3 npm包libxmljs,exec-sync和path,这些都已成功安装。 Meteor应用程序代码和.meteor文件夹将复制到docker镜像内的/home/app
。但是当我尝试运行Meteor应用程序时,我收到以下错误。
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)
如果有人能够解释错误的原因并建议在docker容器中运行meteor应用程序的解决方案或解决方法,我将不胜感激。
答案 0 :(得分:2)
node
图片没有ps
命令。
$ 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:/#
通过向您的Dockerfile添加ps command
指令,在图像上使用另一个具有ps
或安装RUN
命令的基本映像。
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
我测试了它,它工作正常。
$ 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/
答案 1 :(得分:0)
尝试phusion/passenger-docker。它被宣传为Meteor应用程序的ready2use docker镜像。