About docker in GDG Seoul
Upcoming SlideShare
Loading in...5
×
 

About docker in GDG Seoul

on

  • 1,007 views

About docker

About docker

Statistics

Views

Total Views
1,007
Views on SlideShare
766
Embed Views
241

Actions

Likes
12
Downloads
16
Comments
0

2 Embeds 241

http://www.smallake.kr 238
https://twitter.com 3

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    About docker in GDG Seoul About docker in GDG Seoul Presentation Transcript

    • Lightweight Linux Container Docker를 활용한 개발 환경 구축하기 2014.03.26 in GDG Seoul 1 judekim ( 레진엔터테인먼트 )
    • speaker 2 김영찬 ( @modestjude ) http://judekim.tistory.com ! * PHP/Java developer * baas.io in KT * KPNS ( Push Notification ) * 레진엔터테인먼트 서버개발자 ! Previously * KTH, KT
    • Index • docker란? • inside docker • requirements • docker 사용하기 • demo • vagrant 와의 비교 • 개발 환경을 한번 구축해보자 • epilogue 3
    • docker란?
    • docker [dɒkəә] 부두노동자
    • docker [dɒkəә] 부두노동자
    • • docker is an open-source engine that automates the deployment of any application as a lightweight, portable, self- sufficient container that will run virtually anywhere.
    • docker • dotCloud 내부 프로젝트로 시작 (2013.01) • python -> go • dotcloud, Inc. -> docker, Inc • $15M series Funding • v0.8 - new architecture • v0.9 - libcontainer
    • • like git vagrant@precise64:~$ Pulling repository centos 539c0211cd76: Downloading 61.8 MB/98.56 MB (63%) ~/workspace/usergrid-stack-origin:~$ remote: Counting objects: 291, done. remote: Compressing objects: 100% (121/121), done. remote: Total 210 (delta 79), reused 170 (delta 42) Receiving objects: 100% (210/210), 48.34 KiB, done. Resolving deltas: 100% (79/79), completed with 38 local objects. From github.com:apigee/usergrid-stack sudo docker pull centos:6.4 git pull origin master
    • • like git vagrant@precise64:~$ Pulling repository centos 539c0211cd76: Downloading 61.8 MB/98.56 MB (63%) ~/workspace/usergrid-stack-origin:~$ remote: Counting objects: 291, done. remote: Compressing objects: 100% (121/121), done. remote: Total 210 (delta 79), reused 170 (delta 42) Receiving objects: 100% (210/210), 48.34 KiB, done. Resolving deltas: 100% (79/79), completed with 38 local objects. From github.com:apigee/usergrid-stack sudo docker pull centos:6.4 git pull origin master
    • • like git vagrant@precise64:~$ Pulling repository centos 539c0211cd76: Downloading 61.8 MB/98.56 MB (63%) ~/workspace/usergrid-stack-origin:~$ remote: Counting objects: 291, done. remote: Compressing objects: 100% (121/121), done. remote: Total 210 (delta 79), reused 170 (delta 42) Receiving objects: 100% (210/210), 48.34 KiB, done. Resolving deltas: 100% (79/79), completed with 38 local objects. From github.com:apigee/usergrid-stack sudo docker pull centos:6.4 git pull origin master
    • Evolution of IT
    • The challenge
    • NxM Matrix
    • NxM Matrix Dependency hell!!
    • 비슷한 사례가 없었을까?
    • 1960년 이전의 화물운송
    • 마찬가지로 NxM Matrix
    • 마찬가지로 NxM Matrix Also hell!!
    • 그럼 어떻게 해결했을까?
    • 화물 운송의 해결책은?
    • NxM 문제가 해결되었다!
    • container로 만들어진 에코시스템
    • 그렇다면 우리의 해결책은?
    • docker는 container 관리 시스템이다
    • docker는 상황을 더 단순하게 만듭니다.
    • docker는 상황을 더 단순하게 만듭니다.
    • • 나의 container 내(in)에 있는 것들에 대해서... • my code • my libraries • my package manager • my app • my data 개발자의 관심
    • build once and run anywhere ( for developers )
    • • container 밖의 것들에 대해서... • logging • remote access • network configuration • monitoring 시스템 운영자의 관심
    • configure once run anything
    • Linux containers • run everywhere • 커널 버전과 관계없이 • Host 배포판과 관계없이 • run anything • Host에서 동작한다면 container에서도 동작한다. • 즉, 리눅스 커널에서 동작한다면 가능하다.
    • docker는 마찬가지로 (linux)contianer를 사용하여 NxM 문제를 해결했습니다.
    • containers before docker
    • containers before docker
    • containers after docker
    • containers after docker
    • • docker is an open-source engine that automates the deployment of any application as a lightweight, portable, self- sufficient that will run virtually anywhere.
    • • docker is an open-source engine that automates the deployment of any application as a lightweight, portable, self- sufficient that will run virtually anywhere. container
    • docker inside
    • docker에서 사용된 기술들 • LinuX Container ( LXC ) • namespaces • cgroups • layered file system
    • Linux containers?
 lightweight vm • own process space • own network interface • can run stuff as root • can have its own /sbin/init
 ( different from the host )
    • Linux containers?
 a chroot on steroids • can also not have its own /sbin/init • container = isolated process(es) • share kernel with host • no device emulation
 ( neither HVM nor PV )
    • containers vsVMs ( Hypervisor Type2 ) • VM runs on(above) the host operating system as a full fledged OS and uses isolated process spaces. • Docker runs with host operating system as its share the host process spaces.
    • containers vsVMs
    • docker 경량화의 비법 델타 Δ
    • requirements 38
    • requirements • Platforms • Ubuntu,Arch Linux, Gentoo, Fedora, openSUSE, FrugalWare • Provisioning instructions (VM ) • MacOS, windows,Amazon EC2, Rackspace, Google Cloud 39
    • docker 사용하기
    • docker container 기본 flow build push search pull run
    • docker commands • ps • images • pull • build • commit • cp • images • attach • rm • rmi • run • tag
    • demo 43
    • Hello world 44
    • vagrant와의 비교 45
    • 46 vagrant = docker
    • 46 vagrant = docker Vagrantfile = Dockerfile
    • 46 vagrant = docker Vagrantfile = Dockerfile vm vs container
    • vagrant vs docker 47 Feature vagrant docker virtualization type VM ( virtual machine ) VE ( virtual environment ) guaranteed resources at hardware level? Yes No Supported platforms Linux, Unix,Windows Linux, OS x - Windows ( using virtual machine ) boot time a few minutes a few second config file Vagrantfile Dockerfile
    • vagrant vs docker • vagrant는Virtual Machine 를 관리하기 위한 용도로 사용한다. ( on host ) • docker는Virtual Environment를 관리하기 위 한 용도로 사용한다. ( with host ) 48
    • vagrant vs docker • vagrant는Virtual Machine 를 관리하기 위한 용도로 사용한다. ( on host ) • docker는Virtual Environment를 관리하기 위 한 용도로 사용한다. ( with host ) 48
    • VM vs container • 서로 상호 보완 관계 • VM은 하드웨어 리소스의 chunk를 할당하는 데 가장 유용합니다. • container는 소프트웨어 전달 단위로서 매우 가볍고 완벽하게 프로세스 수준에서 작동합니 다. 49
    • apache in ubuntu 12.04 vagrant • ubuntu 12.04 이미지를 다운로드 (vagrant init ) • vm 실행 (vagrant up) • vagrant ssh 접속 • apt-get 으로 apache2 설치 • port forward 설정 • apache start 50
    • apache in ubuntu 12.04 docker • ubuntu 12.04 다운로드 ( docker pull ubuntu ) • container 접속 : docker run -i -t ubuntu: 12.04 /bin/bash • apt-get 으로 apache 설치 • docker 이미지 생성 ( docker commit ) • docker 실행 ( docker run -d ) 51
    • 개발환경을 구축해보자
    • apache2 + php5 53
    • 기존 개발환경 vagrant 를 활용한 다중 vm 을 사용 54
    • 일단 만들기 전에 55
    • 환경( _system ) + 소스 ( src ) ! https://github.com/judeKim/_develop 56
    • create docker image (1) #> docker pull ubuntu #> docker run -i -v=/workspace/_system/L:/ _system -v=/workspace/src:/www -v=/ workspace/logs:/_logs -t ubuntu:precise /bin/bash docker#> vi /etc/apt/sources.list ( ftp.daum.net ) docker#> apt-get update docker#> apt-get install apache2 php5 57
    • create docker image (2) docker#> mv /etc/apache2 /_system/apache2 docker#> mv /etc/php5 /_system/php5 docker#> ln -s /_system/apache2 /etc/apache2 docker#> ln -s /_system/php5 /etc/php5 docker#> mkdir /_logs/apache 58
    • create docker image (3) docker#> docker commit -run '{"Cmd": [ "/usr/ sbin/apache2ctl", "-D", "FOREGROUND" ], "Dns" : ["8.8.8.8"], "PortSpecs" : [ "127.0.0.1:80:80" ] }' 8c26f9a4c58a judekim/ apache2-php5:0.1 59
    • 실행하기 #> docker run -d -p 8080:80 --privileged -h dev-web -v=/workspace/_system/L:/_system - v=/workspace/src:/www -v=/workspace/_logs:/ _logs judekim/apache2-php5:0.1 #> docker run -d -p 80:80 --privileged -h dev- web -v=/workspace/_system/P:/_system -v=/ workspace/src:/www -v=/workspace/_logs:/ _logs judekim/apache2-php5:0.1 60
    • push to public repository ( index.docker.io ) 61
    • mysql 62
    • mysql - Dockerfile • FROM ubuntu:saucy • MAINTAINER Fernando Mayo <fernando@tutum.co> ! • # Install packages • RUN apt-get update • RUN DEBIAN_FRONTEND=noninteractive apt- get -y install supervisor mysql-server pwgen 63
    • mysql - Dockerfile • # Add image configuration and scripts • ADD start.sh /start.sh • ADD run.sh /run.sh • ADD supervisord-mysqld.conf /etc/supervisor/conf.d/supervisord- mysqld.conf • ADD my.cnf /etc/mysql/conf.d/my.cnf • ADD create_mysql_admin_user.sh /create_mysql_admin_user.sh • ADD import_sql.sh /import_sql.sh • RUN chmod 755 /*.sh ! • EXPOSE 3306 • CMD ["/run.sh"] 64
    • 유의사항 및 특징 • foreground 로 실행되도록 daemon을 설정해주어야 한다. ( mysqld_safe, apache2ctl -D FORGROUND ) • hosts 파일은 아직 수정이 불가능하다. 
 (https://github.com/dotcloud/docker/issues/3851) • host의 디렉토리를 마운트 하는 경우 Dockerfile로 만들 수 없다. • 쉘 접속이 기본적이지 않아 설정을 수정하는데 번거롭다. • 다중 daemon을 실행하려면 우회적인 방법을 사용해야 한 다. 65
    • epilogue 66
    • docker use cases 67
    • • testing • build your own PaaS • web based environment for instruction • easy application deployment • create secure sandboxes • create your own SaaS • automated application deployment • continuous integration and deployment : travis • lightweight desktop virtualization 68
    • similar to docker ( lem-kut-fee ) 69
    • 감사합니다 70 https://www.facebook.com/groups/korea.docker.user.group/! ! Korea Docker User Group