[mosh youtube] Docker Tutorial - (1) Docker Action

2021. 4. 25. 17:57개발공부/Docker Tutorial

앱 런칭 단계에 있는 스타트업의 서버 API 개발 포지션 면접을 보면서 Docker에 대해 공부해보았습니다. 반드시 Docker를 써야되진 않지만 일전에 배포했던 앱 서비스가 Docker를 사용했다 말씀하셔서 mosh youtube로 Docker Tutorial 강좌를 들어봤습니다. 

 

저는 토이 프로젝트에서 배포할 때 AWS EC2(Virtual Machine) 인스턴스를 썼는데, Docker의 장점으로는 가볍고 빠르단 장점이 있다고 합니다. 우선 host OS를 그대로 쓸 수 있기 때문에 OS를 다시 받을 필요가 없기 때문에 하드웨어 리소스(CPU, memory 할당... 등)도 VM보다 적게 필요됩니다.

 

(강의내용은 영문으로 작성했습니다.)


Intro

 - Docker is building, running, shipping application. Version, files are not matter of running problem.

https://www.youtube.com/watch?v=pTFZFxd4hOI&t=881s

  - docker-compose up: Execute application by container, automatically download packages.

   - docker-compose down --rmi all : Remove not using files


Container & Virtualmachine

 - Container : isolated environment for running an application

  - need a single OS of the host

  - quick and light weight

  - need less hardware resources

  - running multiple apps in isolation

 - VM : An abstraction of a machine

  - Hypervisors : VirtualBox, VMware

  - Has advantage of running different environment application in same machine.

  - Has disadvantage of needs a full OS, slow, resource intensive(CPU, memory→that need to be allocated, ...)


Architecture

https://www.youtube.com/watch?v=pTFZFxd4hOI&t=881s
https://www.youtube.com/watch?v=pTFZFxd4hOI&t=881s

 - Container shares the kernel of the host : core of OS. part that manages application. including hardware resources(CPU, memory)

  💡Each OS has own kernels with different APIs. Window(win+lin), Linux(lin), Mac(lin VM)


Install

Docker install link 

- Need to install WSL(Windows Subsystem for Linux) or Hyper-V(Only Win 10 pro) for kernel

  Hardware assistance... & data execution... Error : enable Hyper-V in windows features


Development Workflow

 - Dockerize Application : Add docker file in application.

https://www.youtube.com/watch?v=pTFZFxd4hOI&t=881s

 - upload in Docker hub(Registry of Docker img) lets other device execute app

https://www.youtube.com/watch?v=pTFZFxd4hOI&t=881s

 

 - typical way to deploy app program

  - 4 steps : install Node(execution environment for JS), copy files, run node app.js

  - Instead we can write this instructions in docker file and package up our app

1
2
3
4
//Dockerfile
FROM node:alpine
COPY . /app
WORKDIR /app
CMD node app.js
cs

    - set image(node, ... etc ; can look up in Docker registry) and distribution(alpine... etc) 

   - copy files

    - docker build -t hello-docker → img is intalled in a complicated way(don't need to worry)

    - docker image ls : see all image files


Deploy Examination

 - play with docker

  - in advance need upload img in Docker repo

  - can deploy without downloading node environment


2부에서 이어집니다.


출처 : Mosh 유튜브(Docker Tutorial for Beginners 2021)