단계1. hello.js 확인
1
2
3
4
5
6
7
8
9
10
11
12
13
| const http = require('http');
const os = require('os');
console.log("Test server starting...");
const handler = function(req, res) {
console.log("Received request from "+req.connection.remoteAddress);
res.writeHead(200);
res.end("Container Hostname: "+os.hostname()+"\n");
};
let www = http.createServer(handler);
www.listen(8080);
|
단계2. Dockerfile 확인
단계3. Dockerfile과 hello.js이 있는 폴더로 이동
터미널을 열고 Dockerfile, hello.js 파일 확인
단계4. Dockerfile을 이용하여 hellojs 이미지 생성
- docker build -t <이미지명>:<태그> <기준이 되는="" 폴더="" 위치="">기준이>태그>이미지명>
1
| docker build -t hellojs:latest
|
단계5. 생성된 hellojs 이미지 확인
단계6. hellojs-web 컨테이너 생성
1
| docker run --name hellojs-web -d -p 8080:8080 hellojs
|
단계7. 작동중인 hellojs-web 컨테이너 확인
단계8. hellojs-web에 접속
단계9. 실행중인 컨테이너 삭제
1
2
| docker rm -f hellojs-web
docker ps -a
|
단계10. 도커허브 -> repositories -> 아이디 확인
- 도커허브 : https://hub.docker.com/
단계11. 도커 로그인
단계12. 도커허브아아디/ 이미지명
- docker tag <이미지명>:<태그> <도커허브아이디>/<이미지명>:<태그>태그>이미지명>도커허브아이디>태그>이미지명>
1
2
| docker tag hellojs:latest goodwon593/hellojs:latest
docker image ls # 생성된 이미지 확인
|
도커허브로 이미지 업로드
- docker push <도커허브아이디>/<이미지명>:<태그>태그>이미지명>도커허브아이디>
1
| docker push yeongha/hellojs
|
단계14. 도커허브에서 이미지 업로드 확인