-
Notifications
You must be signed in to change notification settings - Fork 9
/
btc-docker-lab4
46 lines (33 loc) · 1.12 KB
/
btc-docker-lab4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
애플리케이션 소스 코드를 포함한 컨테이너 빌드하기
1. nodejs 애플리케이션 컨테이너 빌드하기
$ mkdir appjs
$ cd appjs/
$ cat > app.js
const http = require('http');
const os = require('os');
console.log("Test server starting…");
var handler = function(req, res) {
res.writeHead(200);
res.end("Container Hostname: " + os.hostname() + "\n");
};
var www = http.createServer(handler);
www.listen(8080);
$ cat > Dockerfile
FROM node:12
COPY app.js /app.js
ENTRYPOINT ["node", "app.js"]
2. 컨테이너 빌드
$ docker build -t appjs .
3. 빌드 된 컨테이너 확인
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
appjs latest 12cfd448b8eb 21 seconds ago 918MB
4. 빌드한 컨테이너 실행해보기
$ docker run -d --name appjs appjs
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
be999811a5d6 appjs "node app.js" 5 seconds ago Up 4 seconds appjs
$ curl 172.17.0.2:8080
Container Hostname: be999811a5d6
5. 실행되었던 컨테이너를 종료하자.
$ docker rm -f appjs