Node.js Hello World
Node.js Hello World on CentOS using docker.
Prerequisites
- centos7
- git
- docker
- Node.js & npm
Getting Started
SSH into centos7,下载代码:
客户端连接 cd /opt/www git clone git@github.com:fffy2366/docker-node-hello.git
安装依赖包:
cd docker-node-hello make install
创建 docker image:
make build # docker build -t gasi/centos-node-hello .
Run app:
make run-container # docker run -p 49160:8080 -d gasi/centos-node-hello
Install
curl
:sudo apt-get install curl
Get mapped port (last column) using, e.g. 49160:
docker ps > # Example > ID IMAGE COMMAND CREATED STATUS PORTS > ecce33b30ebf gasi/centos-node-hello:latest node /src/index.js 10 seconds ago Up 9 seconds 49160->8080
Test app using the port in previous step, e.g. 49160:
curl localhost:<port> # Example # curl localhost:49160
It should print
Hello World
to the console.
Acknowledgements
Many thanks to @shykes and @unclejack for their support on IRC as well as the
@dotCloud team for docker.
Ref:https://docs.docker.com/examples/nodejs_web_app/
常用命令
- 删除没有TAG的image(TAG为):
docker rmi -f (docker images | grep "^<none>" | awk "{print3}”)
Ref:
[深入浅出Docker(二):Docker命令行探秘]http://www.infoq.com/cn/articles/docker-command-line-quest/
[docker详细的基础用法]http://m.oschina.net/blog/313109
- [Docker —— 从入门到实践]http://dockerpool.com/static/books/docker_practice/index.html
- [Docker学习笔记之一,搭建一个JAVA Tomcat运行环境]http://www.blogjava.net/yongboy/archive/2013/12/12/407498.html
- [在Docker容器之间拷贝数据:原理与操作示例]http://cloud.51cto.com/art/201412/460660.htm
- [Remove Untagged Images From Docker] http://jimhoskins.com/2013/07/27/remove-untagged-docker-images.html
- [Docker创建centos的LNMP镜像]http://www.vckai.com/p/31
- [docker-lnmp]https://github.com/vukor/docker-lnmp