docker lightweight linux container at Deview 2013 1 judekim ( baas.io developer - KT ) 13년 10월 15일 화요일
Jan 13, 2015
dockerlightweight linux container
at Deview 2013
1
judekim ( baas.io developer - KT )
13년 10월 15일 화요일
speaker
2
김영찬 ( @modestjude )http://judekim.tistory.com
* PHP/Java developer* baas.io in KT* KPNS ( Push Notification )
Previously* KTH
13년 10월 15일 화요일
Index• about docker
• why docker?
• inside docker
• demo
• docker use cases
• limitations
• epilogue
3
13년 10월 15일 화요일
• why docker?
• inside docker
• demo
• docker use cases
• limitations
• epilogue
about docker
13년 10월 15일 화요일
• 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.
6
13년 10월 15일 화요일
• docker는 거의 어디에서나 실행되는 경량이면서 portable하고, 자급자족인 컨테이너 응용 프로그램의 배포를 자동화하는 오픈소스 엔진입니다.
7
13년 10월 15일 화요일
• docker는 거의 어디에서나 실행되는 경량이면서 portable하고, 자급자족인 컨테이너 응용 프로그램의 배포를 자동화하는 오픈소스 엔진입니다.
7
what??
13년 10월 15일 화요일
• git clone https://github.com/dotcloud/docker.git
• vagrant up (http://www.vagrantup.com)- Ubuntu64bit package box download- boot using virtualbox- docker install ( lxc-docker )
• vagrant ssh
9
13년 10월 15일 화요일
10
run CentOS6.4 in Ubuntu
http://youtu.be/xL9e8YaugSY
13년 10월 15일 화요일
hello world
11
http://youtu.be/w4jfLy633xM
13년 10월 15일 화요일
• dotCloud 내부 프로젝트로 시작 (2013.01)
• python -> go
• docker는 현재 다음 기술들로 구현됨 LinuX ContainersControl Groups & NamespacesAUFS
12
docker
13년 10월 15일 화요일
• like git
13
vagrant@precise64:~$ Pulling repository centos539c0211cd76: 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
13년 10월 15일 화요일
• like git
13
vagrant@precise64:~$ Pulling repository centos539c0211cd76: 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
13년 10월 15일 화요일
• like git
13
vagrant@precise64:~$ Pulling repository centos539c0211cd76: 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
13년 10월 15일 화요일
• about docker
• inside docker
• demo
• docker use cases
• limitations
• epilogue
why docker
13년 10월 15일 화요일
• 나의 container 내(in)에 있는 것들에 대해서...
• my code
• my libraries
• my package manager
• my app
• my data
개발자의 관심
13년 10월 15일 화요일
• container 밖의 것들에 대해서...
• logging
• remote access
• network configuration
• monitoring
시스템 운영자의 관심
13년 10월 15일 화요일
Linux containers• run everywhere
• 커널 버전과 관계없이
• Host 배포판과 관계없이
• run anything
• Host에서 동작한다면 container에서도 동작한다.
• 즉, 리눅스 커널에서 동작한다면 가능하다.
13년 10월 15일 화요일
• docker is an open-source engine that automates the deployment of any application as a lightweight, portable, self-sufficient that will run virtually anywhere.
13년 10월 15일 화요일
• 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
13년 10월 15일 화요일
• about docker
• why docker
• demo
• docker use cases
• limitations
• epilogue
inside docker
13년 10월 15일 화요일
Linux containers란 무엇인가?
• own process space
• own network interface
• can run stuff as root
• can have its own /sbin/init(different from the host)
13년 10월 15일 화요일
Linux containers란 무엇인가?
• own process space
• own network interface
• can run stuff as root
• can have its own /sbin/init(different from the host)
그것은 경량화된 VM이다.
13년 10월 15일 화요일
Linux containers란 무엇인가?
• own process space
• own network interface
• can run stuff as root
• can have its own /sbin/init(different from the host)
[Machine Container]
그것은 경량화된 VM이다.
13년 10월 15일 화요일
Linux containers란 무엇인가?
• can also not have its own /sbin/init
• container = isolated process(es)
• share kernel with host
• no device emulation(neither HVM nor PV)
13년 10월 15일 화요일
Linux containers란 무엇인가?
• can also not have its own /sbin/init
• container = isolated process(es)
• share kernel with host
• no device emulation(neither HVM nor PV)
스팀팩 맞은 chroot
13년 10월 15일 화요일
Linux containers란 무엇인가?
• can also not have its own /sbin/init
• container = isolated process(es)
• share kernel with host
• no device emulation(neither HVM nor PV)
[Application Container]
스팀팩 맞은 chroot
13년 10월 15일 화요일
containers vs VMs ( Hypervisor Type2 )
• VM runs on(above) the host operating system as a full fledged OS and uses isolated process spaces.( virtualbox, VMware, Parallels Desktop ... )
• Docker runs with host operating system as its share the host process spaces.
13년 10월 15일 화요일
containers이어야 하는 이유• speed : boots in seconds
• footprint : 100-1,000 containers on one machine.
13년 10월 15일 화요일
LinuX Container ( LXC )
• 또 다른 리눅스 시스템에서 리눅스 시스템을 구동
• container는 리눅스 박스내의 process 그룹
• container 안에서는 VM처럼 보임
• container 밖에서는 process 처럼 보임
• 스팀팩 맞은 chroot
46
13년 10월 15일 화요일
Isolation with namespaces
48
• pid ( processes )
• net ( network interfaces, routing ... )
• ipc ( System V IPC )
• mnt ( mount points, filesystems )
• uts ( hostname )
• user ( UIDs )
13년 10월 15일 화요일
AUFS ( Advanced multi layered Unification FileSystem )
• layered 파일 시스템
• 최상위 layer만 읽기 쓰기가 가능한 layer로 설정되어 있음 ( container )
• rootfs(루트파일시스템)에 있는 내용을 수정할 수 있으나, 수정한 내용은 rw 디렉토리로 이동된다.
50
13년 10월 15일 화요일
rootfs
• 일반적인 디렉토리를 포함한다. ( /dev, /bin, /etc )
• 환경설정 및 실행파일 그리고 라이브러리파일들이 rootfs에 있다. ( like bash, ls ... )
54
13년 10월 15일 화요일
- 전통적인 linux 부팅 순서 . rootfs를 읽기 전용으로 마운트 . rootfs 무결성 검사 . rootfs를 읽기쓰기 모드로 변경- docker 는 오직 rootfs를 읽기 전용으로 마운트 한다. 대신 읽기쓰기가 가능한 레이어를 추가한다. ( it's )
Layer
55
13년 10월 15일 화요일
- 전통적인 linux 부팅 순서 . rootfs를 읽기 전용으로 마운트 . rootfs 무결성 검사 . rootfs를 읽기쓰기 모드로 변경- docker 는 오직 rootfs를 읽기 전용으로 마운트 한다. 대신 읽기쓰기가 가능한 레이어를 추가한다. ( it's )
Layer
55
container
13년 10월 15일 화요일
- 읽기 전용 레이어 image로 부름- image는 상태를 가질 수 없음- 부모 image가 없는 image를 base image라고 함 ( e.g. Debian )
Image
56
13년 10월 15일 화요일
- 읽기쓰기가 가능한 레이어- 최상위 레이어- 상태를 가질 수 있음- container를 docker의 commit 명령어를 통해 이미지로 만들수도 있으며 만든 이미지를 다시 parent image로 사용할 수 있음. 즉 재사용할 수 있음.
Container
57
13년 10월 15일 화요일
59
Union file system• 일반적으로 리눅스에서는 디렉토리 하나에 하나의 파일시스템만 마운트하는게 대부분.
• 만일 동일한 디렉토리에 둘 이상의 파일 시스템을 마운트하면 항상 마지막에 마운트한 파일 시스템 내용만 보여 이전에 마운트한 파일 시스템 내용은 접근이 불가능.
• 병합(union)마운트란 하나의 디렉토리에 여러 파일시스템을 마운트 하여 여러 파일 시스템 내용이 합쳐지는 것을 의미.
• 나중 마운트한 파일이 우선시 됨. 만일 writable mount가 되었다면 마운트 파일을 지웠을때, 그 정보도 유지됨.
13년 10월 15일 화요일
60
Demo union file system in docker
http://youtu.be/uHLs5ljV20U
13년 10월 15일 화요일
60
http://youtu.be/uHLs5ljV20U
13년 10월 15일 화요일
좀전에 ubuntu image에서 /tmp/test2파일을 추가한것은
container의 rootfs에서는 확인이 되나,
rw 에서는 확인이 되지 않습니다.
61
13년 10월 15일 화요일
rootfs는 image를 모두 가지고 있고, 그 위에 변화하는 값까지 가지고 있으나,
rw는 image대비 변화값(Δ델타)만을 가지고 있기 때문입니다.
62
13년 10월 15일 화요일
69
• 프로세스들은 고립되어 있지만, host위에서 직접 실행된다.
• CPU performance
- native performance ( 거의 차이 없음 )
• memory performance
- a few % shaved off for (optional) accounting
• network performance
- 작은(small)의 오버헤드 발생. ( docker project 팀은 향후에 충분히 1:1에 가까운 수준으로 최적화 가능하다라고 함 )
13년 10월 15일 화요일
docker benchmarkitems method host docker
CPU sysbench 1
memory
sysbenchseq
1 (r)
memory
sysbenchseq 1 (w)memory
sysbenchrnd
1 (r)memory
sysbenchrnd 1 (w)
disk dd 1
network iperf 1
13년 10월 15일 화요일
docker benchmarkitems method host docker
CPU sysbench 1
memory
sysbenchseq
1 (r)
memory
sysbenchseq 1 (w)memory
sysbenchrnd
1 (r)memory
sysbenchrnd 1 (w)
disk dd 1
network iperf 1
0.9931
0.99990.97591.00560.98070.9716
13년 10월 15일 화요일
docker benchmarkitems method host docker
CPU sysbench 1
memory
sysbenchseq
1 (r)
memory
sysbenchseq 1 (w)memory
sysbenchrnd
1 (r)memory
sysbenchrnd 1 (w)
disk dd 1
network iperf 1
0.9931
0.99990.97591.00560.98070.9716
0.7889
13년 10월 15일 화요일
• about docker
• why docker
• inside docker
• docker use cases
• limitations
• epilogue
demo
13년 10월 15일 화요일
hipache + nginx with php5
https://github.com/dotcloud/hipache
72
13년 10월 15일 화요일
1. php + nginx로 구현된 web application 서버들을 hipache를 통해 로드밸런싱 구현
2. web application 수정 및 deploy
74
13년 10월 15일 화요일
로드밸런싱 => hipache 사용
76
• git clone https://github.com/dotcloud/hipache.git
• sudo docker build -t dotcloud/hipache .
13년 10월 15일 화요일
nginx + php5• git clone https://github.com/darron/docker-
nginx-php5.git
• 간단히 Dockerfile을 수정한다.
• RUN echo "<?php echo sprintf( \"Hello world2 - (%s)\", \$_SERVER['SERVER_ADDR']); ?>" > /var/www/index.php
• sudo docker build -t judekim/nginx-php5 .
77
13년 10월 15일 화요일
demo
78
http://youtu.be/xC-2b7iGBno
13년 10월 15일 화요일
• about docker
• why docker
• inside docker
• demo
• limitations
• epilogue
docker use cases
13년 10월 15일 화요일
• 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
80
13년 10월 15일 화요일
유닛 테스팅
82
• 자신의 환경과 테스트를 분리하기 위해 컨테이너를 사용
• 테스트후에 data등을 정리 하기 위해 더이상 신경쓰지 않아도 됨
• 다중 머신에 걸친 테스트도 문제 없음
13년 10월 15일 화요일
시스템 테스팅• 쉽게 테스트와 다른 시스템 환경설정을 만들수 있음
• 테스트서버가 끊기거나 재구축에 대해서 더이상 걱정할 필요 없음
• 사용예 : Test Fabric script(http://agiliq.com/blog/2013/06/self-testing-fabfile-using-docker/)
83
13년 10월 15일 화요일
Continuous integration• 개별 소스 커밋에 대해서 유닛 테스트를 할 수 있음
• StriderCD.com - Open source CI server
• deploy전에 docker 컨테이너를 통해 CI test를 수행
• TravisCI docker를 활용하고 있음
84
13년 10월 15일 화요일
Continuous integration• 개별 소스 커밋에 대해서 유닛 테스트를 할 수 있음
• StriderCD.com - Open source CI server
• deploy전에 docker 컨테이너를 통해 CI test를 수행
• TravisCI docker를 활용하고 있음
84
13년 10월 15일 화요일
87
개발 테스트 gitrepository
docker private registry
git clone and
docker build
CI ( test
container )
hook
test pass
13년 10월 15일 화요일
87
개발 테스트 gitrepository
developserver
docker private registry
docker pull
git clone and
docker build
CI ( test
container )
hook
test pass
13년 10월 15일 화요일
87
개발 테스트 gitrepository
developserver
stageserver
docker private registry
docker pull
git clone and
docker build
CI ( test
container )
hook
test pass
13년 10월 15일 화요일
87
개발 테스트 gitrepository
developserver
stageserver
productionserver
docker private registry
docker pull
git clone and
docker build
CI ( test
container )
hook
test pass
13년 10월 15일 화요일
87
개발 테스트 gitrepository
developserver
stageserver
productionserver
docker private registry
docker pull
git clone and
docker build
CI ( test
container )
hook
test pass
13년 10월 15일 화요일
• about docker
• why docker
• inside docker
• demo
• docker use cases
• epiloguelimitations
13년 10월 15일 화요일
• about docker
• why docker
• inside docker
• demo
• docker use cases
• limitations
epilogue
13년 10월 15일 화요일
• 2013-08-08 - 새로운 아키텍쳐 계획 발표
• 2013-08 mid - 0.6 릴리즈
• 2013-10 - 0.8 릴리즈 ( 새로운 아키텍쳐 )
• 2013-10 ~ 11 0.8 certified on RHEL, CentOS (http://blog.docker.io/2013/09/red-hat-and-docker-collaborate/)
docker 로드맵
13년 10월 15일 화요일
• 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*.
13년 10월 15일 화요일
• Stabilizing
• Shrink and stabilize Core
• Provide stable, pluggable API
• Expanding runtime environments
• OpenStack : announced
• Docker as various flavors of VM ( AMI, vdf, etc )
• Increase compatible kernel set
• Increase compatible Union FS set
• IaaS compatibility
• Dev/devops tools integrations
• Chef, Puppet, Vagrant, Github, Travis, Buildbot
• Various flavors of PaaS & IDE
docker v1.0
13년 10월 15일 화요일
similar to docker ( lem-kut-fee )
https://github.com/google/lmctfy
since 2013.10.02
13년 10월 15일 화요일
references• http://docker.io
• http://blog.docker.io
• http://blog.dotcloud.com/
• http://lxc.sourceforge.net/
• http://en.wikipedia.org/wiki/Operating_system-level_virtualization
• http://aufs.sourceforge.net/
• https://github.com/erikh/docker-bench
13년 10월 15일 화요일
why docker
• docker의 경우 linux container의 주요 기능에 몇몇 편리함 및 공유를 덧붙였을뿐이지 않은가? 직접 linux container를 사용해서 구현해도 되지 않을까?
13년 10월 15일 화요일