hello.js 소스
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('Hello World');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
docker build -t hellojs:latest .
컨테이너 이름 : tag .
마지막의 .은 현재 directory기준이라는 뜻이다.
FROM ubuntu:18.04
LABEL maintainer="sample"
RUN apt-get update \
&& apt-get install -y apache2
RUN echo "TEST WEB" > /var/www/html/index.html
EXPOSE 80
CMD ["/usr/sbin/apache2ctl","-DFOREGROUND"]
docker build -t webserver:v1 .
docker run -d -p 80:80 --name web webserver:v1
docker ps
curl localhost:80
docker rm -f web
배포를 하기위해 가장 첫번째 해야하는건 docker hub에 로그인을 하는것이다.
실습하는 방법에따라 다르지만 도커를 설치하려면 로그인을 했을것이기 때문에 따로 다루지는 않겠다.
docker login
docker images
docker tag webserver:v1 도커허브에 사용하는 네임/webserver:v1
docker tag hellojs:latest 도커허브에 사용하는 네임/hellojs:latest
소스 출처 : https://opentutorials.org/module/938/6770
내용 출처 : https://www.youtube.com/watch?v=WLjfzwdASbw&list=PLApuRlvrZKogb78kKq1wRvrjg1VMwYrvi&index=12