Apps
Bin/Libs
Guest OS
Hypervisor
Host OS
Server
Apps
Guest OS
VM
VM
Bin/Libs
VM
Apps
Bin/Libs
Guest OS
VM
同じ独立性を確保しながら、よ
り少ないリソースで動作する
Apps
Bin/Libs
Apps
Bin/Libs
Apps
Bin/Libs
Docker Engine
Host OS
Server
Container
Container
Container
VMとコンテナ
Container
kernelは共有
コンテナの動作
Container Process Container
Docker Engine
Host OS
Server
Process
process A
process B
process C Docker EngineがHost OSから
各リソースを隔離する
Process
boot2docker
Process
Container
Process
Container
Process
Docker Daemon
boot2docker (linux)
TCP 2375
Docker
Command VirtualBox
Mac OS X
APIを使ってDockerを制御
Mac用DockerはAPIを呼ぶよ
うに作られている
Docker!le
Docker!le
FROM centos:centos6
MAINTAINER Masahiro Nagano <kazeburo@gmail.com>
RUN yum install -y http://download.fedoraproject.org/
pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
RUN yum install -y sl
CMD sl
元となるイメージ
build時に実行する
コマンド
docker run時に
実行するコマンド
Dockerイメージの作成 #0
Mac OS X
$ ls
Dockerfile Vagrantfile
$ vagrant ssh
Guest OS
$ cd /vagrant
$ ls
Dockerfile Vagrantfile
$ docker build -t localdev/sl .
自動でGuestOSに
マウントされる
イメージに付けるTag名
差分イメージの枝構造
FROM centos:centos6
RUN yum install -y epel.rpm
RUN yum install -y sl
CMD sl
FROM centos:centos6
RUN yum install -y epel.rpm
RUN yum install -y fortune
CMD fortune
centos6
base
epel
sl
CMD
差分イメージの枝構造
FROM centos:centos6
RUN yum install -y epel.rpm
RUN yum install -y sl
CMD sl
FROM centos:centos6
RUN yum install -y epel.rpm
RUN yum install -y fortune
CMD fortune
centos6
base
epel
sl
CMD
差分イメージの枝構造
FROM centos:centos6
RUN yum install -y epel.rpm
RUN yum install -y sl
CMD sl
FROM centos:centos6
RUN yum install -y epel.rpm
RUN yum install -y fortune
CMD fortune
centos6
base
epel
sl
Docker!leに変更を加えると
そこから枝が分かれる。
幹は共有する
CMD
差分イメージの枝構造
FROM centos:centos6
RUN yum install -y epel.rpm
RUN yum install -y sl
CMD sl
FROM centos:centos6
RUN yum install -y epel.rpm
RUN yum install -y fortune
CMD fortune
centos6
base
epel
sl fortune
Docker!leに変更を加えると
そこから枝が分かれる。
幹は共有する
CMD CMD
System Perl
Guest OS
$ docker run -i -t ubuntu:14.04 bash
root@8ac58f29a17a:/# perl -v
This is perl 5, version 18, subversion 2 (v5.18.2) built for
x86_64-linux-gnu-thread-multi
(with 41 registered patches, see perl -V for more detail)
Copyright 1987-2013, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
root@8ac58f29a17a:/#
ubuntuの場合
System Perl
Guest OS
$ docker run -i -t centos:centos6 bash
bash-4.1# perl -v
CentOSの場合
System Perl
Guest OS
$ docker run -i -t centos:centos6 bash
bash-4.1# perl -v
bash: perl: command not found
bash-4.1#
CentOSの場合
CentOSはイメージサイズを小さくする
ために perl は削られている!
kazeburo/perl の使い方
Guest OS
$ docker run -i -t kazeburo/perl:v5.18 perl -v
This is perl 5, version 18, subversion 1 (v5.18.1) built for
x86_64-linux
Copyright 1987-2013, Larry Wall
..
$
kazeburo/perl の使い方
Docker!le
FROM kazeburo/perl:v5.18
RUN cpanm -n Plack
CMD plackup -v
cpanmも導入済み
GuestOS
$ docker build -t localdev/perl .
$ docker run localdev/perl
Plack 1.0031
$