$ mkdir centos7-expressjs
$ cd centos7-expressjs
$ vi Dockerfile
FROM centos:centos7
RUN yum install -y epel-release;yum install -y npm;
RUN npm install express --save
COPY . ./src
EXPOSE 8080
CMD ["node", "/src/index.js"]
$ vi index.js
var express = require('express'), app = express();
app.get('/', function (req, res) {res.send('Hello World!\n');});
app.listen(8080);
$ docker build -t knight76/centos7-expressjs .
$ docker run -p 8081:8080 -d knight76/centos7-expressjs
$ curl -i localhost:8081
HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: text/html; charset=utf-8
Content-Length: 13
ETag: W/"d-jd2L5LF5pSmvpfL/rkuYWA"
Date: Tue, 26 Jul 2016 09:43:28 GMT
Connection: keep-alive
Hello World!
----------------------
도커 허브에 업로드 한다.
우선 https://hub.docker.com에 이메일 계정으로 가입한다.
$ docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username:
Password:
Login Succeeded
$ docker push knight76/centos7-expressjs
(한국이라 그런지, push 시간이 오래 걸린다.)
$ docker search expressjs
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
dmportella/expressjs Simple expressjs site with a status route ... 0
....
knight76/expressjs ...
'docker' 카테고리의 다른 글
[docker] mac 디렉토리를 docker container (linux) 디렉토리로 복사할 때 유의점 (0) | 2016.07.29 |
---|---|
docker container 실행에 중요한 /data/start.sh (0) | 2016.07.29 |
[docker] wordpress 테스트 환경 구축 (0) | 2016.07.24 |
docker 공부 (0) | 2016.07.24 |
[docker] docker 설치 (0) | 2016.07.22 |