script 실행할 entrypoint 설정

2023. 10. 6. 11:28docker

python
  • 파일 생성

이미지를 빌드하기 위한 파일 생성

 

 

스크립트 파일 생성

 

 

  • 이미지 빌드

docker build -t helloworld .

현재 디렉토리에서 Dockerfile을 찾아서 해당 Dockerfile을 기반으로 helloworld 이미지를 빌드하고,
이 이미지에 helloworld라는 태그를 붙인다.

 

확인

 

 

  • script 실행

docker run helloworld

확인

 

 

nodejs
  • 패키지 설치

curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -

sudo apt-get install -y nodejs
sudo npm install -g express 
sudo npm install -g express-generator

npm init -y
npm i express

 

 

  • 파일 생성

const express = require('express');
const app = express();
var port = 7000;
app.get('/', (req, res) => {
        res.send('hello world by nodejs');
});

app.listen(port, (req, res) => {
        console.log('hello world test is running now on ' + port);
});

스크립트 파일 생성

 

 

FROM node:16-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY app.js ./
ENTRYPOINT ["node","app.js"]

이미지를 빌드할 파일 생성

 

 

  • 이미지 빌드

docker build -t nodejs:1.0 .

확인

 

 

  • 도커 실행

docker run -d -p 8080:7000 nodejs:1.0

확인

 

 

로그 확인

 

 

웹 페이지 접속

'docker' 카테고리의 다른 글

nodejs 실습  (0) 2023.10.06
Docker commit  (0) 2023.10.06
volume  (0) 2023.10.05
dockerhub 활용  (0) 2023.10.05
network  (0) 2023.10.05