我尝试让我的节点应用程序在本地的Docker容器中运行。我正在使用boot2docker。 节点应用程序的结构如下: todolistdocker> todoapp> package.json + server.js +其他文件夹(www,...)
我的泊坞窗文件如下:
# retrive the node docker image from bluemix node image
FROM registry-ice.ng.bluemix.net/ibmnode:latest
# retrieve the app source code
RUN git clone https://github.com/edevregille/todolistdocker.git
WORKDIR todolistdocker/todoapp
RUN npm install
# expose port
EXPOSE 6001
#launch the app
CMD ["node", "server.js"]
当我运行命令
时docker build -t manu/todoapp .
我得到以下日志
Sending build context to Docker daemon 323.6 kB
Sending build context to Docker daemon
Step 0 : FROM registry-ice.ng.bluemix.net/ibmnode:latest
Pulling repository registry-ice.ng.bluemix.net/ibmnode
96ed152ebea0: Download complete
83e4dde6b9cf: Download complete
b670fb0c7ecd: Download complete
29460ac93442: Download complete
d2a0ecffe6fa: Download complete
4bb543ba4efd: Download complete
edc4127366f7: Download complete
406f719b3e59: Download complete
18bafbc626ab: Download complete
ff1106e6dfc2: Download complete
4f7397e97d5c: Download complete
cf5c60a7eab1: Download complete
2af8b62ffa5f: Download complete
Status: Downloaded newer image for registry ice.ng.bluemix.net/ibmnode:latest
---> 96ed152ebea0
Step 1 : RUN git clone https://github.com/edevregille/todolistdocker.git
---> Running in 9112add4fa4b
Cloning into 'todolistdocker'...
---> e9f4ac002a2c
Removing intermediate container 9112add4fa4b
Step 2 : WORKDIR todolistdocker/todoapp
---> Running in 8cbfb49a73cd
---> 68e04a64b395
Removing intermediate container 8cbfb49a73cd
Step 3 : RUN npm install
---> Running in 4f8643e83210
npm WARN package.json bluemix-todo-apps-node@0.1.0 No repository field.
> bson@0.1.5 install /todolistdocker/todoapp/node_modules/monk/node_modules/mongoskin/node_modules/mongodb/node_modules/bson
> node install.js || (exit 0)
================================================================================
= =
= Attempting to build bson c++ extension =
= Windows: no build will be attempted as binaries are prepackaged =
= Unix: on failure the package will still install without the C++ extension =
= =
================================================================================
node-gyp clean
node-gyp configure build
make[1]: Entering directory `/todolistdocker/todoapp/node_modules/monk/node_modules/mongoskin/node_modules/m ongodb/node_modules/bson/build'
CXX(target) Release/obj.target/bson/ext/bson.o
SOLINK_MODULE(target) Release/obj.target/bson.node
SOLINK_MODULE(target) Release/obj.target/bson.node: Finished
COPY Release/bson.node
make[1]: Leaving directory `/todolistdocker/todoapp/node_modules/monk/node_modules/mongoskin/node_modules/m ongodb/node_modules/bson/build'
child process exited with code 0
ports@1.1.0 node_modules/ports
expect.js@0.3.1 node_modules/expect.js
underscore@1.6.0 node_modules/underscore
q@1.0.1 node_modules/q
nopt@2.2.1 node_modules/nopt
└── abbrev@1.0.7
coffee-script@1.7.1 node_modules/coffee-script
└── mkdirp@0.3.5
mocha@1.17.1 node_modules/mocha
├── diff@1.0.7
├── growl@1.7.0
├── commander@2.0.0
├── debug@2.2.0 (ms@0.7.1)
├── mkdirp@0.3.5
├── jade@0.26.3 (commander@0.6.1, mkdirp@0.3.0)
└── glob@3.2.3 (inherits@2.0.1, graceful-fs@2.0.3, minimatch@0.2.14)
cfenv@0.2.0 node_modules/cfenv
└── js-yaml@3.0.2 (argparse@0.1.16, esprima@1.0.4)
nano@4.7.1 node_modules/nano
├── underscore@1.5.2
├── errs@0.2.4
├── request@2.33.0 (forever-agent@0.5.2, aws-sign2@0.5.0, qs@0.6.6, oauth- sign@0.3.0, tunnel-agent@0.3.0, json-stringify-safe@5.0.1, mime@1.2.11, node-
10.1, form-data@0.1.4, hawk@1.0.0, tough-cookie@2.0.0)
└── follow@0.10.4 (debug@0.7.4, browser-request@0.3.3, request@2.30.0)
---> 21281d872464
Removing intermediate container 4f8643e83210
Step 4 : EXPOSE 6001
---> Running in 5d23a27e6c8c
---> 2b0b679643cf
Removing intermediate container 5d23a27e6c8c
Step 5 : CMD node todoapp/server.js
---> Running in 75cfaa646d09
---> 2346739e9613
Removing intermediate container 75cfaa646d09
Successfully built 2346739e9613
然后,我运行了docker
docker@boot2docker:~$ docker run -d -p 6001:6001 manu/todoapp
1ef378b6679cebb316db81b6c843d559180496ba798ea82f728a9f81eb64d757
我没有任何容器在运行......
docker@boot2docker:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
docker@boot2docker:~$
知道出了什么问题吗?
答案 0 :(得分:1)
容器可能会关闭,因为node.js守护程序无法启动或死亡。
以交互模式启动它 docker -i -t [image name] / bin / bash 并以交互方式尝试您的命令以检查node.js守护程序是否正常启动