# Use the official Ubuntu base image
FROM ubuntu:latest
# Update package list and install Node.js
RUN apt-get update
RUN apt-get install -y nodejs
RUN apt-get install -y npm
# Set the working directory in the container
WORKDIR /app
# Copy package.json and package-lock.json to the container
COPY package.json ./
# Install app dependencies
RUN npm install
# Copy the application files to the container
COPY . .
# Expose the port the app runs on
EXPOSE 3000
# Command to run the application
CMD ["npm", "start"]
# Add a command to create a start_success file in /tmp/
RUN touch /tmp/start_success
-t nodejs-docker-example: 빌드한 이미지의 태그를 지정합니다. -f Dockerfile-custom: 사용할 도커파일을 지정합니다. 여기서는 Dockerfile-custom을 사용합니다. .: 현재 디렉토리를 빌드 컨텍스트로 사용합니다. 즉, 현재 디렉토리에 있는 모든 파일과 도커파일을 빌드에 포함시킵니다.
docker run -p 3000:3000 --name my-nodejs nodejs-docker-example
앞 3000포트는 호스트(로컬머신)의 포트입니다.
뒤 3000포트는 컨테이너의 포트입니다.
두 포트를 매핑합니다.
컨테이너 이름은 my-nodejs 로 하였습니다.
컨테이너 내부를 접근하고 싶다면
docker exec -it my-nodejs /bin/bash 로 접속해서 볼 수 있습니다.
크롬에서 http://localhost:3000 을 요청하게 되면 Hello World!를 볼 수 있습니다.
virtualbox를 활용하여 가상머신 virtual machine(이하 vm)에서 쿠버네티스를 설치, 운영하는 것을 해보려고 한다.
virtualbox 설치, ubuntu 20.04 설치는 이 포스트에서 다루지 않는다.
구글 검색 추천!
총 3개의 vm을 준비한다.
node1 192.168.50.61
node2 192.168.50.62
node3 192.168.50.63
--
1) ubuntu 20.04
필요한 셋팅을 아래 순서대로 진행한다.
sudo apt install net-tools
sudo vi /etc/sudoers
# User privilege specification
root ALL=(ALL:ALL) ALL
sunsh ALL=(ALL) NOPASSWD:ALL
sudo vi /etc/sudoers.d/sunsh
sunsh ALL=(ALL) NOPASSWD:ALL
네트워크
sudo vi 00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
enp0s3:
dhcp4: true
enp0s8:
dhcp4: no
addresses:
- 192.168.50.61/24
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
enp0s9:
dhcp4: no
addresses:
- 192.168.50.61/24
version: 2