DevOps with Docker

39
© 2015 IBM Corporation 개발자와 함께하는 친친親親 DAY! 개발자가 개발되는 시간, 50MM/DD/YY DevOps with Docker 황상철/SK planet

Transcript of DevOps with Docker

Page 1: DevOps with Docker

© 2015 IBM Corporation

개발자와 함께하는 친친親親 DAY! 개발자가 개발되는 시간, 50분 MM/DD/YY

DevOps����������� ������������������  with����������� ������������������  Docker����������� ������������������  

황상철/SK����������� ������������������  planet����������� ������������������  

Page 2: DevOps with Docker

© 2015 IBM Corporation 2

Page header content goes here

강사����������� ������������������  소개����������� ������������������  

황상철����������� ������������������  ����������� ������������������  

Platform����������� ������������������  Architecture����������� ������������������  Team����������� ������������������  /SK����������� ������������������  planet����������� ������������������  

• 2015:����������� ������������������  Docker����������� ������������������  기반����������� ������������������  인프라����������� ������������������  구축중����������� ������������������  • 2013~14:����������� ������������������  빌드/배포����������� ������������������  시스템����������� ������������������  개발/적용����������� ������������������  

Page 3: DevOps with Docker

© 2015 IBM Corporation 3

Page header content goes here

Agenda����������� ������������������  

§ ����������� ������������������  도커는����������� ������������������  무엇인가����������� ������������������  § ����������� ������������������  이미지와����������� ������������������  컨테이너����������� ������������������  

§ ����������� ������������������  도커를����������� ������������������  어떻게����������� ������������������  사용할까����������� ������������������  § ����������� ������������������  도커����������� ������������������  기반의����������� ������������������  개발과����������� ������������������  운영����������� ������������������  

����������� ������������������  

Page 4: DevOps with Docker

© 2015 IBM Corporation

도커는����������� ������������������  무엇인가����������� ������������������  

Introduction of Docker

Page 5: DevOps with Docker

© 2015 IBM Corporation 5

Page header content goes here

도커(Docker)����������� ������������������  

리눅스����������� ������������������  컨테이너����������� ������������������  기술을����������� ������������������  이용해����������� ������������������  어플리케이션����������� ������������������  패키징,����������� ������������������  배포를����������� ������������������  지원하는����������� ������������������  오픈소스����������� ������������������  프로젝트����������� ������������������  

*����������� ������������������  경량,����������� ������������������  가상화����������� ������������������  솔루션����������� ������������������  

Page 6: DevOps with Docker

© 2015 IBM Corporation 6

Page header content goes here

도커(Docker)����������� ������������������  

PyCon2013에서����������� ������������������  Solomon����������� ������������������  Hykes의����������� ������������������  ‘Hello����������� ������������������  World’����������� ������������������  데모로����������� ������������������  처음����������� ������������������  소개����������� ������������������  

The����������� ������������������  future����������� ������������������  of����������� ������������������  Linux����������� ������������������  containers(http://goo.gl/QR7jr7)����������� ������������������  

����������� ������������������  $����������� ������������������  docker����������� ������������������  run����������� ������������������  busybox����������� ������������������  echo����������� ������������������  ‘Hello����������� ������������������  World’����������� ������������������  

Page 7: DevOps with Docker

© 2015 IBM Corporation 7

Page header content goes here

docker����������� ������������������  run����������� ������������������  busybox����������� ������������������  echo����������� ������������������  ‘Hello����������� ������������������  World’����������� ������������������  ����������� ������������������  ����������� ������������������  

1.If(busybox����������� ������������������  이미지����������� ������������������  없으면)����������� ������������������  {����������� ������������������  

����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  dockerhub에서����������� ������������������  다운로드}����������� ������������������  

2.Busybox이미지로����������� ������������������  새로운����������� ������������������  컨테이너����������� ������������������  실행����������� ������������������  

3.TTY로����������� ������������������  ‘Hello����������� ������������������  World’����������� ������������������  출력����������� ������������������  

4.유닉스����������� ������������������  소켓으로����������� ������������������  결과����������� ������������������  전송����������� ������������������  

Page 8: DevOps with Docker

© 2015 IBM Corporation 8

Page header content goes here

14년말기준����������� ������������������  1억����������� ������������������  다운로드����������� ������������������  

Page 9: DevOps with Docker

© 2015 IBM Corporation 9

Page header content goes here

특징1:����������� ������������������  사용하기����������� ������������������  쉽다����������� ������������������  

리눅스����������� ������������������  컨테이너는����������� ������������������  소개된지����������� ������������������  10년이����������� ������������������  지난����������� ������������������  오래된����������� ������������������  기술이다.����������� ������������������  하지만����������� ������������������  설정이����������� ������������������  복잡하고����������� ������������������  사용하기����������� ������������������  어려워����������� ������������������  널리����������� ������������������  사용되지����������� ������������������  못했음.����������� ������������������  

Page 10: DevOps with Docker

© 2015 IBM Corporation 10

Page header content goes here

특징2:����������� ������������������  가볍다����������� ������������������  

VM에����������� ������������������  비해����������� ������������������  이미지����������� ������������������  파일����������� ������������������  크기가����������� ������������������  작아서����������� ������������������  이미지를����������� ������������������  만들고����������� ������������������  실행하는����������� ������������������  시간이����������� ������������������  적게����������� ������������������  걸린다.����������� ������������������  

����������� ������������������  

Linux����������� ������������������  베이스����������� ������������������  이미지����������� ������������������  

ubuntu����������� ������������������  latest����������� ������������������  ba5877dc9bec����������� ������������������  4����������� ������������������  days����������� ������������������  ago����������� ������������������  192.7����������� ������������������  MB����������� ������������������  

centos����������� ������������������  latest����������� ������������������  1a7dc42f78ba����������� ������������������  2����������� ������������������  weeks����������� ������������������  ago����������� ������������������  236.4����������� ������������������  MB����������� ������������������  

fedora����������� ������������������  latest����������� ������������������  88b42ffd1f7c����������� ������������������  10����������� ������������������  days����������� ������������������  ago����������� ������������������  373.7����������� ������������������  MB����������� ������������������  

Page 11: DevOps with Docker

© 2015 IBM Corporation 11

Page header content goes here

얼마나����������� ������������������  가벼워야����������� ������������������  가벼운����������� ������������������  걸까����������� ������������������  

*����������� ������������������  임베디드����������� ������������������  리눅스����������� ������������������  커널을����������� ������������������  이용한����������� ������������������  4MB����������� ������������������  리눅스����������� ������������������  베이스이미지.����������� ������������������  

*����������� ������������������  16MB����������� ������������������  PostgreSQL����������� ������������������  서버(jpetazzo/pglite)����������� ������������������  

*����������� ������������������  Raspberry����������� ������������������  PI용����������� ������������������  도커����������� ������������������  

(Raspbian����������� ������������������  Wheezy,Docker����������� ������������������  1.4.1)����������� ������������������  

����������� ������������������  

Page 12: DevOps with Docker

© 2015 IBM Corporation 12

Page header content goes here

리눅스����������� ������������������  컨테이너(LXC)����������� ������������������  

단일����������� ������������������  리눅스����������� ������������������  호스트에����������� ������������������  격리된(isolated)����������� ������������������  리눅스����������� ������������������  시스템을����������� ������������������  여러개����������� ������������������  실행하는����������� ������������������  OS����������� ������������������  수준의����������� ������������������  가상화����������� ������������������  ����������� ������������������  

§ ����������� ������������������  OpenVZ(openvz.org)����������� ������������������  § ����������� ������������������  Imctfy(google/Imctfy)����������� ������������������  § ����������� ������������������  Warden(cloudfoundry/warden)����������� ������������������  

Page 13: DevOps with Docker

© 2015 IBM Corporation 13

Page header content goes here

LXC����������� ������������������  vs����������� ������������������  VM����������� ������������������  

Page 14: DevOps with Docker

© 2015 IBM Corporation 14

Page header content goes here

도커가����������� ������������������  지원하는����������� ������������������  Host����������� ������������������  OS����������� ������������������  

리눅스����������� ������������������  커널버전����������� ������������������  3.8.0x86_64����������� ������������������  이상으로����������� ������������������  Device����������� ������������������  Mapper가����������� ������������������  설치된����������� ������������������  환경.����������� ������������������  

§ ����������� ������������������  Ubuntu,CentOS,RHEL����������� ������������������  

§ ����������� ������������������  CoreOS����������� ������������������  § ����������� ������������������  Debian,����������� ������������������  SUSE,����������� ������������������  Fedora,����������� ������������������  etc����������� ������������������  

Page 15: DevOps with Docker

© 2015 IBM Corporation 15

Page header content goes here

도커����������� ������������������  아키텍처����������� ������������������  

Page 16: DevOps with Docker

© 2015 IBM Corporation 16

Page header content goes here

Boot2Docker����������� ������������������  

MacOS����������� ������������������  X와����������� ������������������  윈도우즈는����������� ������������������  리눅스����������� ������������������  커널을����������� ������������������  지원하지����������� ������������������  않기����������� ������������������  때문에����������� ������������������  도커를����������� ������������������  실행할수����������� ������������������  없다.����������� ������������������  Boot2Docker는����������� ������������������  도커����������� ������������������  데몬을����������� ������������������  실행하는����������� ������������������  가벼운����������� ������������������  가상머신����������� ������������������  관리도구.����������� ������������������  

Tiny����������� ������������������  Core����������� ������������������  Linux����������� ������������������  기반����������� ������������������  

Page 17: DevOps with Docker

© 2015 IBM Corporation 17

Page header content goes here

Page 18: DevOps with Docker

© 2015 IBM Corporation

이미지와����������� ������������������  컨테이너����������� ������������������  

Image and Container

Page 19: DevOps with Docker

© 2015 IBM Corporation 19

Page header content goes here

도커����������� ������������������  이미지����������� ������������������  

레이어����������� ������������������  파일����������� ������������������  시스템으로����������� ������������������  각����������� ������������������  파일시스템이����������� ������������������  곧����������� ������������������  이미지.����������� ������������������  읽기전용����������� ������������������  파일시스템으로����������� ������������������  도커가����������� ������������������  어플리케이션을����������� ������������������  배포하는����������� ������������������  단위.����������� ������������������  

§ ����������� ������������������  bootfs:����������� ������������������  도커����������� ������������������  시스템이����������� ������������������  사용하는����������� ������������������  파일시스템����������� ������������������  § ����������� ������������������  union����������� ������������������  mount:����������� ������������������  여러����������� ������������������  파일시스템을����������� ������������������  하나의����������� ������������������  파일����������� ������������������  시스템으로����������� ������������������  보이게����������� ������������������  ����������� ������������������  

Page 20: DevOps with Docker

© 2015 IBM Corporation 20

Page header content goes here

Page 21: DevOps with Docker

© 2015 IBM Corporation 21

Page header content goes here

DockerHub����������� ������������������  

도커����������� ������������������  이미지를����������� ������������������  공유하는����������� ������������������  저장소.����������� ������������������  github����������� ������������������  계정으로����������� ������������������  사용가능.����������� ������������������  많은����������� ������������������  오픈소스����������� ������������������  공식����������� ������������������  이미지가����������� ������������������  관리되고����������� ������������������  있다.����������� ������������������  

Page 22: DevOps with Docker

© 2015 IBM Corporation 22

Page header content goes here

Dockerfile����������� ������������������  

도커����������� ������������������  이미지를����������� ������������������  만들기����������� ������������������  위해����������� ������������������  설치할����������� ������������������  SW,����������� ������������������  필요한����������� ������������������  설정을����������� ������������������  정의하는����������� ������������������  파일.����������� ������������������  

§ ����������� ������������������  프로비저닝(Provisioning)����������� ������������������  역할����������� ������������������  

§ ����������� ������������������  이미지����������� ������������������  제작����������� ������������������  과정을����������� ������������������  기록����������� ������������������  ����������� ������������������  

Page 23: DevOps with Docker

© 2015 IBM Corporation 23

Page header content goes here

nginx를����������� ������������������  위한����������� ������������������  Dockerfile����������� ������������������  

#����������� ������������������  Version:����������� ������������������  0.0.1����������� ������������������  FROM����������� ������������������  ubuntu:14.04����������� ������������������  MAINTAINER����������� ������������������  Sangcheol����������� ������������������  Hwang����������� ������������������  "[email protected]"����������� ������������������  ����������� ������������������  RUN����������� ������������������  apt-get����������� ������������������  update����������� ������������������  RUN����������� ������������������  apt-get����������� ������������������  install����������� ������������������  -y����������� ������������������  nginx����������� ������������������  RUN����������� ������������������  echo����������� ������������������  'Hi,����������� ������������������  I����������� ������������������  am����������� ������������������  in����������� ������������������  your����������� ������������������  container'����������� ������������������  ����������� ������������������  EXPOSE����������� ������������������  80����������� ������������������  

Page 24: DevOps with Docker

© 2015 IBM Corporation 24

Page header content goes here

Dockerfile����������� ������������������  명령어����������� ������������������  

FROM:����������� ������������������  베이스����������� ������������������  이미지����������� ������������������  지정����������� ������������������  

ENV:����������� ������������������  환경변수����������� ������������������  정의����������� ������������������  

RUN:����������� ������������������  환경구성에����������� ������������������  필요한����������� ������������������  명령����������� ������������������  실행����������� ������������������  

CMD:����������� ������������������  컨테이너����������� ������������������  구동될때����������� ������������������  실행되는����������� ������������������  명령어����������� ������������������  

COPY,ENTRYNET,VOLUME,USER…⋯����������� ������������������  

Page 25: DevOps with Docker

© 2015 IBM Corporation 25

Page header content goes here

도커����������� ������������������  컨테이너����������� ������������������  

읽기/쓰기가����������� ������������������  가능한����������� ������������������  파일����������� ������������������  시스템으로����������� ������������������  이미지를����������� ������������������  실행한것.����������� ������������������  ����������� ������������������  ����������� ������������������  

DB,Web,WAS,등����������� ������������������  VM으로����������� ������������������  실행하는����������� ������������������  대부분����������� ������������������  SW����������� ������������������  실행가능.����������� ������������������  

Page 26: DevOps with Docker

© 2015 IBM Corporation 26

Page header content goes here

데이터����������� ������������������  볼륨����������� ������������������  컨테이너����������� ������������������  

호스트����������� ������������������  디렉토리를����������� ������������������  컨테이너와����������� ������������������  공유할때는����������� ������������������  VOLUME을����������� ������������������  사용.����������� ������������������  컨테이너����������� ������������������  간에����������� ������������������  VOLUME을����������� ������������������  공유하는����������� ������������������  컨테이너.����������� ������������������  

$����������� ������������������  docker����������� ������������������  run����������� ������������������  -d����������� ������������������  -P����������� ������������������  --name����������� ������������������  web����������� ������������������  -v����������� ������������������  src/webapp:/opt/webapp����������� ������������������  nginx����������� ������������������  

$����������� ������������������  docker����������� ������������������  run����������� ������������������  -d����������� ������������������  -P����������� ������������������  --name����������� ������������������  web����������� ������������������  --volumes-from����������� ������������������  datacontainer����������� ������������������  nginx����������� ������������������  

Page 27: DevOps with Docker

© 2015 IBM Corporation

도커를����������� ������������������  어떻게����������� ������������������  사용할까����������� ������������������  

Use cases of Docker

Page 28: DevOps with Docker

© 2015 IBM Corporation 28

Page header content goes here

US1:����������� ������������������  독립된����������� ������������������  로컬����������� ������������������  개발환경����������� ������������������  

로컬����������� ������������������  설정에����������� ������������������  영향을����������� ������������������  받지����������� ������������������  않는����������� ������������������  독립된����������� ������������������  개발환경을����������� ������������������  구성.����������� ������������������  Vagrant를����������� ������������������  이용하면����������� ������������������  일관된����������� ������������������  인터페이스로����������� ������������������  구성이����������� ������������������  가능.����������� ������������������  

Vagrant����������� ������������������  Docker����������� ������������������  provider����������� ������������������  

(http://docs.vagrantup.com/v2/docker/)����������� ������������������  

Page 29: DevOps with Docker

© 2015 IBM Corporation 29

Page header content goes here

도커를����������� ������������������  처음����������� ������������������  쓴다면����������� ������������������  

설치나����������� ������������������  설정이����������� ������������������  필요없는����������� ������������������  boot2docker로����������� ������������������  시작해서����������� ������������������  기본����������� ������������������  사용법을����������� ������������������  익힌다.����������� ������������������  Vagrant로����������� ������������������  별도����������� ������������������  리눅스VM을����������� ������������������  만들고����������� ������������������  직접����������� ������������������  docker를����������� ������������������  설치해서����������� ������������������  사용하자.����������� ������������������  

Page 30: DevOps with Docker

© 2015 IBM Corporation 30

Page header content goes here

US2:����������� ������������������  VM기반의����������� ������������������  도커����������� ������������������  Host����������� ������������������  

VM서버로����������� ������������������  도커����������� ������������������  Host����������� ������������������  구성한다.����������� ������������������  Host에는����������� ������������������  한개����������� ������������������  컨테이너만����������� ������������������  운영하는게����������� ������������������  효과적이다.����������� ������������������  VM����������� ������������������  유형,환경에����������� ������������������  상관없이����������� ������������������  배포가����������� ������������������  가능하다.����������� ������������������  

Docker����������� ������������������  Machine����������� ������������������  

(https://github.com/docker/machine)����������� ������������������  

Page 31: DevOps with Docker

© 2015 IBM Corporation 31

Page header content goes here

US3:����������� ������������������  싱글서버����������� ������������������  도커����������� ������������������  Host����������� ������������������  

물리서버����������� ������������������  1대로����������� ������������������  도커����������� ������������������  Host를����������� ������������������  구성한다.����������� ������������������  여러����������� ������������������  컨테이너를����������� ������������������  운영할수����������� ������������������  있어서����������� ������������������  효율적이다.����������� ������������������  구성이����������� ������������������  단순하여����������� ������������������  관리가����������� ������������������  용이하지만����������� ������������������  서버����������� ������������������  에러에����������� ������������������  대한����������� ������������������  위험성이����������� ������������������  크다.����������� ������������������  ����������� ������������������  

spotify/helios����������� ������������������  

panamax����������� ������������������  

����������� ������������������  

Page 32: DevOps with Docker

© 2015 IBM Corporation 32

Page header content goes here

Panamax����������� ������������������  

도커����������� ������������������  Container����������� ������������������  관리����������� ������������������  도구����������� ������������������  

§  RoR,����������� ������������������  CoreOS����������� ������������������  

§  Template����������� ������������������  개념,����������� ������������������  편리한����������� ������������������  UI����������� ������������������  

Page 33: DevOps with Docker

© 2015 IBM Corporation 33

Page header content goes here

Page 34: DevOps with Docker

© 2015 IBM Corporation 34

Page header content goes here

US4:����������� ������������������  도커����������� ������������������  Host����������� ������������������  클러스터����������� ������������������  

여러����������� ������������������  도커����������� ������������������  Host����������� ������������������  서버를����������� ������������������  하나의����������� ������������������  Host처럼����������� ������������������  관리하기����������� ������������������  위해����������� ������������������  ����������� ������������������  클러스터를����������� ������������������  구성한다.����������� ������������������  컨테이너����������� ������������������  스케쥴링,����������� ������������������  Host����������� ������������������  모니터링����������� ������������������  등이����������� ������������������  필요.����������� ������������������  § ����������� ������������������  fleet����������� ������������������  § ����������� ������������������  swarm����������� ������������������  § ����������� ������������������  kubernets����������� ������������������  § ����������� ������������������  mesos����������� ������������������  

Page 35: DevOps with Docker

© 2015 IBM Corporation

도커기반의����������� ������������������  개발과����������� ������������������  운영����������� ������������������  

DevOps with Docker

Page 36: DevOps with Docker

© 2015 IBM Corporation 36

Page header content goes here

Microservice����������� ������������������  

어플리케이션을����������� ������������������  작은����������� ������������������  서비스����������� ������������������  묶음으로����������� ������������������  개발한다.����������� ������������������  서비스는����������� ������������������  각자����������� ������������������  프로세스로����������� ������������������  동작하고����������� ������������������  서로간에는����������� ������������������  HTTP기반의����������� ������������������  API로����������� ������������������  통신한다.����������� ������������������  

Page 37: DevOps with Docker

© 2015 IBM Corporation 37

Page header content goes here

BlueGreen����������� ������������������  Deployment����������� ������������������  

2개의����������� ������������������  운영환경을����������� ������������������  준비하고����������� ������������������  번갈아서����������� ������������������  배포하는����������� ������������������  방식.����������� ������������������  

Page 38: DevOps with Docker

© 2015 IBM Corporation 38

Page header content goes here

DevOps����������� ������������������  

개발,운영,테스트를����������� ������������������  함께����������� ������������������  진행하는����������� ������������������  문화가����������� ������������������  정착되어야����������� ������������������  한다.����������� ������������������  

Page 39: DevOps with Docker

© 2015 IBM Corporation 39

Page header content goes here

Docker기반����������� ������������������  DevOps����������� ������������������  

개발자는����������� ������������������  로컬에����������� ������������������  컨테이너����������� ������������������  기반����������� ������������������  개발환경����������� ������������������  

바로����������� ������������������  사용가능한����������� ������������������  On-premises����������� ������������������  Docker����������� ������������������  인프라����������� ������������������  제공:����������� ������������������  통합/테스팅����������� ������������������  

내부����������� ������������������  인프라,����������� ������������������  클라우드����������� ������������������  구분없이����������� ������������������  배포����������� ������������������  가능����������� ������������������