• 検索結果がありません。

No05 Handson and Container

N/A
N/A
Protected

Academic year: 2018

シェア "No05 Handson and Container"

Copied!
72
0
0

読み込み中.... (全文を見る)

全文

(1)

ウ 基盤構築演習

Cloud Infrastructure Design and Deployment

5. サー ー仮想化 コンテ の基礎演習

2017.v1

(2)

Table of contents

 本演習 仮想 ー ー 作成 OS ン

ー 実施 OS ン ー

仮想 ー ー 実現 い 実体 情

報 い 確認

 合わ Docker 用い ン 環境 操作

機能 仮想 ー ー 違い ン

技術 実現 い 名前空間 隔離 い

い 理解

 仮想 ー ー 基礎操作

 ン 基礎操作

2

(3)

演習環境につい

(4)

演習環境の概要

 演習用 OpenStack環境上 各自割 当 ン 内 演習 行

o 各環境 生徒 独立

 最初 演習 実施 前 共通演習環境 構築 実施 必要 あ

 前回 演習環境 残 い 場合 演習環境 削除方法 実施

4

openstack

tenant-XX / student-XX tenant-YY / student-YY ・・・

物理 ー ー ッ ワー 装置 ー

資源層

抽象化層

( )

仮想 ー ー

内部 ッ ワー 192.168.199.0/24

共通演習環境

演習環境 演習環境

共通演習環境 構築 実施

構築: 第N回 演習環境 構築 作成

削除: 演習環境 削除方法 実施

各自 端末 操作 行う

(5)

演習環境の削除方法

各演習回の前に 前回の環境を削除するために実施

(6)

演習環境を構築する前の状態

 各演習環境 構築 前 以下 状態 い 事 確認 い

o default 以外 存在 い い

default 共通演習環境 作成

o ー 以外 ソー 存在 い い

 以下 3 画面 確認 い

o ソー や い 場合 次項 手順 削除

6

default

存在 い

Security Groups

外 消費 い い

3 存在

(7)

Stacks の確認

 以下 確認

o Orchestration → Stacks default 以外 存在 い い

default 以外 存在 い 場合 対象 ッ 削除

o 削除 default 以外 選択 Delete Stacks 押下

default

存在 い

hands-on-3

(8)

ソー 消費量の確認

 以下 確認

o Compute → Overview Limit Summary Security

Groups 以外 消費 0 状態

 ソー 残 い 場合 前項 手順 Stacks

確認 不要 ッ 削除 い

 ソー 残 い 場合 次項 手順 個別

ソー 削除 い

8

Security Groups 以外 消費

い い 0 状態 確認

(9)

個別の ソー 削除

 ー 一覧 表示 残

い ソー 削除

o 以下 削除例

削除

Floating IP 削除

キー 削除

(10)

ネッ ワー の状態

 以下 確認

o Network → Network Topology [public] - [Ext-Router] -

[work-net] 状態

 余分 ソー 作成 い 場合 個別 削除

10

3 存在

(11)

第5回 演習環境の構築

(12)

ッ の起動

 左 ー Orchestration → Stacks

選択

 後 Launch Stack 押下

12

第5回

(13)

テンプ ー の指定

 Template Source URL 指定

 Template URL http://<<repo_ip>>/hands-on/05_handson.yaml 指定

o <<repo_ip>> 部分 講師 値 指定 あ

 値 設定 Next 押下

URL 選択

http://<<repo_ip>>/hands-on/05_handson.yaml

第5回

(14)

メー ーの指定

Stack Name hands-on-5 入力

Password 自分 OpenStack ワー 入力

 hands-on repository server

ー IP 入力

o IP 講師 指示 あ

14

hands-on-5

自分 OpenStack ワー

入力

ー ー IP

第5回

(15)

正常終了の確認

 10分前後 作成 完了 Create Complete

o 設定 完了 待 間 後 演習 進 方 確認

 失敗 場合 hands-on-5 選択 Delete Stack 押下 削除

 後 再度作成 や 直 い

第5回

(16)

環境の確認

Network → Network Topology 選択 作成 ッ ワー 環境 確認

 正常 作成 完了 以下 状態 い

o ッ ワー work-net 2 ー ー handson5-virt handson3-docker 接続

16

第5回

(17)

サー ーの確認

Compute → Instances 選択 作成 2 台 ー ー 情報 確認

o handson5-virt ・・・仮想 ー ー 演習用

o handson5-docker ・・・ ン 演習用

2 台 使 演習 進 い

第5回

(18)

イン情報の確認

 作成 ー ー ン 情報 確認

 Orchestration → Stacks → hands-on-5 → Overview 選択 い

o 情報 後 演習 何回 必要 新規 開い 演習

18

第5回

(19)

イン情報

Overview 必要

情報 確認

o instance1,2

 ー ー IP

 ー ー名

 Floating IP

 各自 ー PC IPSSH 行い

o password

 上記2台 ー ー ン

ワー

 ー ー名 centos

 ワー 各自異

 環境 作 び 変わ

o private_key

 各 ン ン 利用

秘密鍵

 ワー 認証 行え 各

PC SSH 設定

ワー 入力

ン 可能

第5回

(20)

仮想サー ーの基礎操作

20

(21)

演習内容

 仮想 ー ー 作成 ー ー 対 各種操作 行い

o 仮想 ッ ワー 作成

o 仮想 ー ー 作成 OS

o 仮想 ー ー 実体 周辺技術 確認

o 仮想 ー ー 構成 ー 仮想 ン 複製

仮想 ー ー

内部 ッ ワー 192.168.199.0/24

handson5-virt

192.168.199.30

eth0

default

仮想 ッ ワー

192.168.100.0/24

my-vm-1

複製

my-vm-2

ン ー

仮想化ー ー 備

え 収容

ー ー

仮想化ー ー上

稼働 仮想 ー ー

用語

(22)

演習サー ー 仮想化ホ への イン

 演習用 ー ー ンソー 画面 接続

o Compute → Instances 選択 ン ン 一覧 表示

o handson5-virt ー 開い Console 選択

22

(23)

演習サー ー 仮想化ホ への イン

 Click here to show only console 新規

(24)

演習サー ー 仮想化ホ への イン

 起動 ンソー centos ー ー ン 行い

o ワー Orchestration 詳細 確認

 ン後 root ー ー 変更 上 ン GUI 起動

o 起動 startx 実行

24

注意

Web ンソー 画面 日本語キー

ー 使 い 場合 記号 配置

崩 い 入力 い記号 存

WEB ンソー 使

ワー 設定等 行わ い い

(25)

演習サー ー 仮想化ホ への イン

 ン ン ン後 初期 ッ ッ ン

ン 表示

o 特 設定 必要 無い キッ

(26)

演習サー ー 仮想化ホ への イン

 ッ 表示 右上 Application Terminal

起動

26

(27)

OS イメー の ウン ー

 仮想 ー ー 起動 OSDVD ー ン ー

wget ン 使 reposerver ン ー

 ン ー ー 仮想 ー ー ー ー 管理 移動

[root@handson5-virt ~]# cd

[root@handson5-virt ~]# wget reposerver/images/Cent7-Mini.iso --2017-04-08 16:43:44-- http://reposerver/images/Cent7-Mini.iso Resolving reposerver (reposerver)... 157.1.141.28

Connecting to reposerver (reposerver)|157.1.141.28|:80... connected. HTTP request sent, awaiting response... 200 OK

Length: 713031680 (680M) [application/octet-stream] Saving to: Cent -Mini.iso

100%[===============================>] 713,031,680 108MB/s in 6.3s

2017-04-08 16:43:50 (107 MB/s) - Cent -Mini.iso saved [ 0 0/ 0 0] [root@handson5-virt ~]# ll -h

total 971M

-rw-r--r--. 1 root root 680M Dec 6 08:44 Cent7-Mini.iso drwxr-xr-x. 2 root root 6 Apr 7 00:23 Desktop

drwxr-xr-x. 2 root root 6 Apr 7 00:23 Documents drwxr-xr-x. 2 root root 6 Apr 7 00:23 Downloads drwxr-xr-x. 2 root root 6 Apr 7 00:23 Music drwxr-xr-x. 2 root root 6 Apr 7 00:23 Pictures drwxr-xr-x. 2 root root 6 Apr 7 00:23 Public drwxr-xr-x. 2 root root 6 Apr 7 00:23 Templates drwxr-xr-x. 2 root root 6 Apr 7 00:23 Videos

[root@handson5-virt ~]# mv Cent7-Mini.iso /var/lib/libvirt/images/

(28)

仮想サー ー ネー ャーの起動

 仮想 ー ー ー ー virt-manager 起動

 起動 virt-manager 利用 演習 操作 行い

28

[root@handson5-virt ~]# virt-manager

(29)

仮想ネッ ワー の構成

 初期状態 作成 仮想 ー ー 接続 ッ ワー 存在

 仮想 ー ー 作成 前 仮想 ッ ワー 構成

ッ い Virtual Network

選択

追加 ン 選択

(30)

仮想ネッ ワー の構成

default いう名前 仮想 ッ ワー 作成

 192.168.100.0/24 いう ッ ワー ・ 割 当

o ッ ワー DHCP 有効化 192.168.100.128-254 自動 割 当

う 構成 い

 仮想 ー ー default 接続 起動 範囲 自動

割 当

 IPv6 無効 設定

30

(31)

仮想ネッ ワー の構成

 default 有効 物理NIC ッ ワー ワー う 構成

Forwarding to physical network 選択

o 設定 作成 仮想 ー ー 外部 ッ ワー 接続

 逆 閉 ッ ワー 構成 い場合 ワー 無効

 ッ ワー 作成 ン 閉

(32)

仮想サー ーの作成

 仮想 ー ー 作成 勧

o File → New Virtual Machine 選択 仮想 ン 作成 ー 起

o Local install media 選択

ー 行い

 他 ー ー ーやPXE ー 別 方法 ン ー 進 可

o Use ISO image → Browse 選択 選択

32

(33)

仮想サー ーの作成

 ン ー 選択画面 先程 ン ー Cent7-Mini.iso 選択

o 表示 い い場合 Refresh ン 押下 更新 行い

 選択 ン ー ー 自動 CentOS 7

検知

(34)

仮想サー ーの作成

2048MB CPU 2 個 選択

10GB 設定

 仮想 ー ー 名前 my-vm-1 作成 い

 最後 Finish 押下 仮想 ー ー 構成 起動

o 仮想 ー ー 起動 指定 起動 OS

ー ー 操作 移

34

2048

2

(35)

OS のイン

 仮想 ー ー 作成 成功 起動 仮想 ー ー上 設定

ン ー 起動

 ン ー ー ー 出 ーソ キー

↓↑ 使 Install CentOS Linux 7 選択 Enter 押下

(36)

OS のイン

 ン ー ー 起動 通常 OS ン ー 同様 ン

ン 従い ン ー 勧

o 仮想 ー ー ンソー い場合 View → Scale

Display → Always 選択 ンソー 解像度

縮小

 ン ー ー 起動 最初 ン ー ー 言語 選択

English 勧 い

36

(37)

OS のイン

 手順 問題

設定部分 △ ー い い

 設定 選択 い

 選択画面

vda 10GB ✓ 記号 付い い 事

確認 Done 選択

 全 項目 △ ー 消え い

事 確認 Begin

Installation 選択

進行中 ー ー 関 設定 行う う

ー ー

root ー ー ワー 設定 ROOT PASSWORD 選択

ワー password 設定

記号 入 い う

Done 選択 ワー 簡単

う警告 出 う一度 Done 選択 確定 可能

root ワー 設定 User Creation △ ー 消え

510分程度 ン ー 終了

(38)

OS のイン

 ン ー 終了 ー 100% 達 画

面右下 Reboot ン 表示 選択 仮想 ー

ー ー い

o 完了 待 間 後 演習 進 方 確認

い い

 ン ー 正常 終了 い 再起動 仮想 ー ー

CentOS 起動 表示

38

(39)

仮想化ホ 上 の仮想サー ーの状態

 起動 仮想 ー ー 状態 仮想化 上 handson5-virt 上 確認

o 各自 端末 handson5-virt ssh root ー ー 切 替え

o 一覧 起動 仮想 ン 確認

 確認 仮想 ー ー 実体 kill 仮想 ー ー 停止 事 同

# ssh centos@xxx.xxx.xxx.xxx centos@157.1.141.121's password:

Last login: Sat Apr 8 16:39:20 2017 from 157.1.141.29 [centos@handson5-virt ~]$ sudo -i

[root@handson5-virt ~]#

[root@handson5-virt ~]# ps -ef |grep my-vm-1

qemu 4819 1 0 408 ? 00:09:25 /usr/libexec/qemu-kvm -name my-vm-1 -S -machine pc-i440fx-rhel7.0.0,accel=kvm,usb=off -cpu Westmere -m 1024 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid 951075a6-3022-46ab-b184-340a4ea291ac -no-user-config - nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/domain-3-my-vm-1/monitor.sock,server,nowait -mon

chardev=charmonitor,id=monitor,mode=control -rtc base=utc,driftfix=slew -global kvm-pit.lost_tick_policy=discard -no-hpet -no-shutdown - global PIIX4_PM.disable_s3=1 -global PIIX4_PM.disable_s4=1 -boot strict=on -device ich9-usb-ehci1,id=usb,bus=pci.0,addr=0x6.0x7 -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x6 -device ich9-usb-

uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x6.0x1 -device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x6.0x2 - device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x5 -drive file=/var/lib/libvirt/images/my-vm-

1.qcow2,format=qcow2,if=none,id=drive-virtio-disk0 -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x7,drive=drive-virtio-disk0,id=virtio- disk0,bootindex=1 -drive if=none,id=drive-ide0-0-0,readonly=on -device ide-cd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -netdev tap,fd=26,id=hostnet0,vhost=on,vhostfd=28 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:21:1f:f4,bus=pci.0,addr=0x3 - chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -chardev

socket,id=charchannel0,path=/var/lib/libvirt/qemu/channel/target/domain-3-my-vm-1/org.qemu.guest_agent.0,server,nowait -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=org.qemu.guest_agent.0 -chardev

spicevmc,id=charchannel1,name=vdagent -device virtserialport,bus=virtio-

serial0.0,nr=2,chardev=charchannel1,id=channel1,name=com.redhat.spice.0 -device usb-tablet,id=input0,bus=usb.0,port=1 -spice

port=5900,addr=127.0.0.1,disable-ticketing,image-compression=off,seamless-migration=on -vga qxl -global qxl-vga.ram_size=67108864 -global qxl-vga.vram_size=67108864 -global qxl-vga.vgamem_mb=16 -device intel-hda,id=sound0,bus=pci.0,addr=0x4 -device hda-duplex,id=sound0- codec0,bus=sound0.0,cad=0 -chardev spicevmc,id=charredir0,name=usbredir -device usb-redir,chardev=charredir0,id=redir0,bus=usb.0,port=2 - chardev spicevmc,id=charredir1,name=usbredir -device usb-redir,chardev=charredir1,id=redir1,bus=usb.0,port=3 -device virtio-balloon- pci,id=balloon0,bus=pci.0,addr=0x8 -msg timestamp=on

root 17733 17685 0 12:45 pts/1 00:00:00 grep --color=auto my-vm-1

handson5-virt

ン情報 Orchestration 確認

1 仮想 ー ー1台 実体

qemu-kvm 大量 ン 与え 確認

ン 仮想 ー ー 接続 ッ ワー 等 情報 与え い

(40)

仮想化ホ 上 の仮想サー ーの状態

 仮想 ー ー 仮想化 上 1 あ 確認

 与え い 大量 ン 実体 確認

o ン 仮想 ー ー 設定 定義 い 与え い

40

[root@handson5-virt ~]# cd /etc/libvirt/qemu/ [root@handson5-virt qemu]# ll

合計 8

-rw---. 1 root root 4347 4 8 17:02 my-vm-1.xml drwx---. 3 root root 40 4 8 16:57 networks [root@handson5-virt qemu]# cat my-vm-1.xml

抜粋

<domain type='kvm'>

<name>my-vm-1</name>

<uuid>951075a6-3022-46ab-b184-340a4ea291ac</uuid>

<memory unit='KiB'>2097152</memory>

<currentMemory unit='KiB'>2097152</currentMemory>

<vcpu placement='static'>2</vcpu> 省略

<devices>

<emulator>/usr/libexec/qemu-kvm</emulator>

<disk type='file' device='disk'>

<driver name='qemu' type='qcow2'/>

<source file='/var/lib/libvirt/images/my-vm-1.qcow2'/>

<target dev='vda' bus='virtio'/>

<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>

</disk> 省略

<interface type='network'>

<mac address='52:54:00:21:1f:f4'/>

<source network='default'/>

<model type='virtio'/>

<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>

</interface> 省略

仮想 ー ー 定義 保存

い 移動

仮想 ー ー my-vm-1

設定 保存

仮想 ー ー 与え やvCPU

定義 い ー

仮想 ー ー 使う 情報

定義 い ー

仮想 ー ー 使う ッ ワー

情報 定義 い ー

(41)

仮想化ホ 上 の仮想サー ーの状態

 仮想 ー ー 接続 い 実体 確認

o 実体 1

o qcow2 いう形式 ー ッ

 qcow2 QEMU Copy On Write 仮想 使用 目的

ー ッ ッ ッ 等 機能 ー い

 他 多数 ー ッ ー い 詳細 qemu-img 確認

[root@handson5-virt qemu]# cd /var/lib/libvirt/images/ [root@handson5-virt images]# ll

合計 2030912

-rw-r--r--. 1 qemu qemu 713031680 12 6 08:44 Cent7-Mini.iso -rw---. 1 qemu qemu 10739318784 4 9 13:07 my-vm-1.qcow2

[root@handson5-virt images]# qemu-img info my-vm-1.qcow2 image: my-vm-1.qcow2

file format: qcow2

virtual size: 10G (10737418240 bytes) disk size: 1.3G

cluster_size: 65536

Format specific information: compat: 1.1

lazy refcounts: true

[root@handson5-virt ~]# qemu-img -h | grep Supported

Supported formats: vvfat vpc vmdk vhdx vdi ssh sheepdog rbd raw host_cdrom host_floppy host_device file qed qcow2 qcow parallels nbd iscsi gluster dmg tftp ftps ftp https http cloop bochs blkverify blkdebug

仮想 ー ー 保存 い

移動 場所 ー ー 変

更 可能

仮想 使わ い

情報 確認 可能

qcow2 形式 10GB

量 持 現在 1.3GB 実際 使わ

い 事 確認

様々 形式 形式 ー い 仮想 操作

qemu-img 形式 実際 仮想 ー ー 起動 qemu-

(42)

仮想サー ーの複製

 仮想 ー ー 実体 2 集約 い い

o 仮想 ー ー 各種設定情報 保存 xml

o 仮想 ー ー 接続

2 複製 仮想 ー ー 複製

o 複製 起動 い 仮想 ー ー上 作成 間違い 複製

確認 う 準備

42

仮想 ー ー ンソー root ー ー

ン ワー ン ー

時 設定 password

[root@localhost ~]# echo "This is your name VM server" >> my-vm-1.txt [root@localhost ~]# cat my-vm-1.txt

This is your name's VM server

[root@localhost ~]# shutdown -h now

複製 ー ー 識別 う

作成

your name 部分 自分 名前 変

更 い

仮想 ー ー 停止

仮想 ー ー 複製 場合 I/O 発生

い う 必要 あ

(43)

仮想サー ーの複製

 仮想 ー ー 停止 確認 2

仮想 ー ー 複製

o 仮想 ー ー 起動 い 状態 不定期 様々 書 込

行わ 時 ー 行う 不整合 発生 可能性 あ

[root@handson5-virt qemu]# virsh list --all

Id Name State

---

- my-vm-1 shut off

[root@handson5-virt ~]# cd /var/lib/libvirt/images/

[root@handson5-virt images]# cp my-vm-1.qcow2 my-vm-2.qcow2 [root@handson5-virt images]# ll

total 4025168

-rw-r--r--. 1 qemu qemu 713031680 Dec 6 08:44 Cent7-Mini.iso -rw---. 1 root root 10739318784 Apr 9 14:02 my-vm-1.qcow2 -rw---. 1 root root 10739318784 Apr 9 14:11 my-vm-2.qcow2

[root@handson5-virt images]# cd /etc/libvirt/qemu/ [root@handson5-virt qemu]# cp my-vm-1.xml my-vm-2.xml [root@handson5-virt qemu]# ll

total 16

-rw---. 1 root root 4347 Apr 8 17:02 my-vm-1.xml -rw---. 1 root root 4347 Apr 9 14:12 my-vm-2.xml drwx---. 3 root root 40 Apr 8 16:57 networks

仮想 ー ー 停止 い

確認

仮想 ー

仮想 ー ー 定義

(44)

仮想サー ーの複製

 仮想 ー ー 定義 my-vm-1.xml 編集

o 仮想 ー ー 名前

o 仮想 ー ー 識別子 あ UUID

o 参照

44

[root@handson5-virt qemu]# uuidgen f681c7ac-974a-43b0-8d6f-9173017a1e12 [root@handson5-virt qemu]# vi my-vm-2.xml

<domain type='kvm'>

<name>my-vm-1</name>

<uuid> 0 a6-3022-46ab-b184-340a4ea291ac</uuid>

<memory unit='KiB'> 0 </memory>

<currentMemory unit='KiB'> 0 </currentMemory>

<vcpu placement='static'> </vcpu>

<os>

<domain type='kvm'>

<name>my-vm-2</name>

<uuid>f681c7ac-974a-43b0-8d6f-9173017a1e12</uuid>

<memory unit='KiB'> 0 </memory>

<currentMemory unit='KiB'> 0 </currentMemory>

<vcpu placement='static'> </vcpu>

<os>

<disk type='file' device='disk'>

<driver name='qemu' type='qcow2'/>

<source file='/var/lib/libvirt/images/my-vm-1.qcow2'/>

<target dev='vda' bus='virtio'/>

<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>

</disk>

<disk type='file' device='disk'>

<driver name='qemu' type='qcow2'/>

<source file='/var/lib/libvirt/images/my-vm-2.qcow2'/>

<target dev='vda' bus='virtio'/>

<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>

</disk>

<interface type='network'>

<mac address='52:54:00:21:1f:f4'/>

<source network='default'/>

<model type='virtio'/>

<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>

</interface>

<interface type='network'>

<mac address='52:54:00:21:1f:f5'/>

<source network='default'/>

<model type='virtio'/>

<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>

</interface>

あ 使うUUID 生成 UUID universally unique

identifier ー ー内や 内 一意 あ 必要 あ ID

使わ uuidgenUUID 生成

変更前 変更後

名前 my-vm-2 uuid

先 生成 新 いID

置 換え

参照 い 仮想

my-vm-

2.qcow2 置 換え

MAC 末尾1桁 新 い値

置 換え

16進数 指定 0-f 使

(45)

仮想サー ーの複製

 ー 編集 仮想 ー ー 定義 新 い仮

想 ー ー 作成

 作成 仮想 ー ー 起動

[root@handson5-virt ~]# cd /etc/libvirt/qemu/ [root@handson5-virt qemu]# ll

total 16

-rw---. 1 root root 4347 Apr 8 17:02 my-vm-1.xml -rw---. 1 root root 4347 Apr 9 14:49 my-vm-2.xml drwx---. 3 root root 40 Apr 8 16:57 networks

[root@handson5-virt qemu]# virsh define my-vm-2.xml Domain my-vm-2 defined from my-vm-2.xml

[root@handson5-virt qemu]# virsh list --all

Id Name State

---

- my-vm-1 shut off

- my-vm-2 shut off

[root@handson5-virt qemu]# virsh start my-vm-2 Domain my-vm-2 started

[root@handson5-virt qemu]# virsh list --all

Id Name State

---

4 my-vm-2 running

- my-vm-1 shut off

先程編集 xml 新 い仮

想 ー ー 定義

新 い仮想 ー ー 作成

ン ン 起動 行い

(46)

仮想サー ーの複製

 ンソー 仮想 ー ー ン 先程作成

存在 い 複製 正 行わ ? 確認

o 複製 仮想 ー ー 仮想 ー ー 同

ワー ン可能 root / password

 仮想 保存 い ワー 情報 一緒 複製 い

46

my-vm-2 ー 表示

Open 選択

ン 作成

存在 い

確認

(47)

補足:コ ン イン の操作

 今回 演習 仮想化 上 GUI 使 操作 行い

同様 各種操作 全 ン ン 行う 可能

以下 一部 紹介

 virsh ン 例

o 一覧 表示: virsh list [--all]

o 仮想 ー ー 起動・停止: virsh (start|destroy) target_vm_name

o 仮想 ー ー ンソー 接続: virsh console target_vm_name

 ンソー 抜 方 Ctrl → Ctrl

o 仮想 ー ー ー : virt-install

 利用方法 参照 い

o 仮想 ー ー 複製: virt-clone

 時間 余裕 あ 方 ン ン 使 3 台目

仮想 ー ー 1台目 複製 い

(48)

コンテ の基礎操作

48

(49)

演習内容

 Docker ン 起動 ン 操作 行い

o 起動 停止

o 同一設定 複数起動 ワー

o 永続化

o 管理

仮想 ー ー

内部 ッ ワー 192.168.199.0/24

handson5-docker

192.168.199.40

eth0

変更

起動 ー 化

起動

ー ワー ッ ン

(50)

演習用サー ーへの接続

 ー ー handson5-docker 接続 root ー ー 変更 演習 行い

o 接続先 ワー Orchestration 参照

o ー ー名 centos

50

# ssh centos@xxx.xxx.xxx.xxx

The authenticity of host '157.1.141.107 (157.1.141.107)' can't be established. ECDSA key fingerprint is 0a:f5:64:9f:a1:73:af:42:8a:33:9b:cb:81:24:58:f9. Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '157.1.141.107' (ECDSA) to the list of known hosts. centos@157.1.141.107's password:

Last login: Thu Mar 31 16:03:09 2016 from 192.168.199.2 [centos@handson5-docker ~]$

[centos@handson5-docker ~]$ sudo -i [root@handson5-docker ~]# docker version Client:

Version: 1.8.2-el7.centos API version: 1.20

Package Version: docker-1.8.2-10.el7.centos.x86_64 Go version: go1.4.2

Git commit: a01dc02/1.8.2 Built:

OS/Arch: linux/amd64 Server:

Version: 1.8.2-el7.centos API version: 1.20

Package Version: Go version: go1.4.2 Git commit: a01dc02/1.8.2 Built:

OS/Arch: linux/amd64

handson5-docker 接続

接続先 IP ワー

Orchestration 確認

接続 root ー ー 切 替え

正常 ッ ッ い docker

ー ン 確認

(51)

コンテ の起動 停止

 演習環境 あ 幾 docker ー ン ー い

 ー 使 CentOS7 ン 作成 bash 起動

o 起動 作成 次項 演習 確認 利用

 起動 bash 終了 ン 一緒 終了 [root@handson5-docker ~]# docker images

REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE docker.io/irixjp/ansible 2.0.1.0_01 543d1f06142a 45 minutes ago 557.8 MB docker.io/jenkins latest 5f5049ed8eb5 6 days ago 709.1 MB docker.io/redmine latest efbf53b9ce8a 13 days ago 587.3 MB docker.io/centos 6 6e93f19d1d37 3 weeks ago 228.9 MB docker.io/centos 7 bb3d629a7cbc 3 weeks ago 196.6 MB docker.io/enakai00/eplite ver1.0 5a25f68ed3c5 3 months ago 729.2 MB docker.io/enakai00/epmysql ver1.0 8a63eb16bbca 3 months ago 339.3 MB [root@handson5-docker ~]# docker run -it centos:7 /bin/bash

[root@3ae3b94973a4 /]# hostname ae3b94973a4

[root@3ae3b94973a4 /]# ps -ef

UID PID PPID C STIME TTY TIME CMD

root 1 0 0 11:18 ? 00:00:00 /bin/bash root 15 1 0 11:23 ? 00:00:00 ps -ef [root@3ae3b94973a4 /]# cd /root

[root@3ae3b94973a4 ~]# echo "file in container" >> test [root@3ae3b94973a4 ~]# cat test

file in container

[root@3ae3b94973a4 ~]# exit [root@handson5-docker ~]#

[root@handson5-docker ~]# docker ps -a

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

"/bin/bash" minutes ago 0 0 seconds ago

環境 問題 docker ー 確認

今回 演習 い ー ー ン

ー あ

ン ー 済 CentOS7 ー ン 作成

い 例 作成 ン 内 bash 起動

仮想 ン 違い 非常 短い時間 起動 い

確認

確認 起動

bash 確認

ン 作成時 指定 終了

ン 停止状態

作成 配置

(52)

コンテ の起動 停止

52

[root@handson5-docker ~]# docker ps -a

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

3ae3b94973a4 centos:7 /bin/bash minutes ago Exited (0) 30 seconds ago distracted_yonath [root@handson5-docker ~]# docker start 3ae3b94973a4

3ae3b94973a4

[root@handson5-docker ~]# docker ps -a

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

3ae3b94973a4 centos:7 "/bin/bash" 9 minutes ago Up 2 seconds distracted_yonath [root@handson5-docker ~]# docker attach 3ae3b94973a4

[root@3ae3b94973a4 /]# cd /root && cat test file in container

[root@3ae3b94973a4 ~]# [root@handson5-docker ~]#

[root@handson5-docker ~]# docker ps -a

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

3ae3b94973a4 centos:7 "/bin/bash" 9 minutes ago Up 27 seconds distracted_yonath [root@handson5-docker ~]# docker run -it --name "2nd-cent7" centos:7 /bin/bash

[root@c10cb48db672 /]#

[root@c10cb48db672 /]# cd /root && cat test cat: test: No such file or directory

[root@c10cb48db672 ~]# hostname c10cb48db672

[root@c10cb48db672 ~]# [root@handson5-docker ~]#

[root@handson5-docker ~]# docker ps -a

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c10cb48db672 centos:7 "/bin/bash" 25 seconds ago Up 23 seconds 2nd-cent7

3ae3b94973a4 centos:7 "/bin/bash" 10 minutes ago Up About a minute distracted_yonath

先ほ 停止 ン 起動

再起動 ン 接続 先ほ 配置

存在 確認 い

ン 終了 ン

Ctrl+p→ Ctrl+q 順 キー 押下

今回 ン 起動 続 い

二 目 ン 起動 今回 ン

名前 起動 い

台目 環境 独立 い 確認

Ctrl+p→ Ctrl+q 環境 抜

(53)

コンテ の起動 停止

 起動 い 2 ン 停止 削除

 基本的 ン 操作

o 指定 作成

o 内 何 操作

o 不要 停止 削除

[root@handson5-docker ~]# docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c10cb48db672 centos:7 "/bin/bash" minutes ago Up minutes 2nd-cent7

ae3b94973a4 centos:7 "/bin/bash" minutes ago Up minutes distracted_yonath

[root@handson5-docker ~]# docker stop ɰae3b94973a4 [root@handson5-docker ~]# docker ps -a

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c10cb48db672 centos:7 "/bin/bash" minutes ago Up minutes nd-cent7

ae3b94973a4 centos:7 "/bin/bash" minutes ago Exited seconds ago distracted_yonath

[root@handson5-docker ~]# docker stop c10cb48db672 [root@handson5-docker ~]# docker ps -a

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c10cb48db672 centos:7 "/bin/bash" minutes ago Exited seconds ago nd-cent7

ae3b94973a4 centos:7 "/bin/bash" minutes ago Exited seconds ago distracted_yonath

[root@handson5-docker ~]# docker rm ɰae3b94973a4 [root@handson5-docker ~]# docker ps -a

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c10cb48db672 centos:7 "/bin/bash" minutes ago Exited seconds ago nd-cent7

[root@handson5-docker ~]# docker rm c10cb48db672 [root@handson5-docker ~]# docker ps -a

台目 停止

台目 停止

台目 削除

台目 削除

(54)

同一設定のサービ の複数起動 ー フォワー

 あ 設定 施 ー 使 全 同 設定 ー 同一 複数起動

o 公式 redmine 利用

入手 起動 あ ゆ 場所 起動 作成 Docker

o 3 起動 ー 3000 側 3000,3001,3002 ー ワー

54

[root@handson5-docker ~]# docker run -d --name redmine1 -p 000: 000 redmine c5fb36a415e7f1a9f337fd109d95acc5ef1d1bcc110c041db6175d0357b2b

[root@handson5-docker ~]# docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c5fb36a41 redmine "/docker-entrypoint.s" seconds ago Up seconds 0.0.0.0: 000-> 000/tcp redmine1 [root@handson5-docker ~]# docker run -d --name redmine2 -p 00 : 000 redmine

0a9792796e06c5aa4c230158f3459627e6505b210e06a351133148f8571fd08

[root@handson5-docker ~]# docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 0a9792796e0 redmine "/docker-entrypoint.s" seconds ago Up seconds 0.0.0.0: 00 -> 000/tcp redmine2

c5fb36a41 redmine "/docker-entrypoint.s" seconds ago Up 0 seconds 0.0.0.0: 000-> 000/tcp redmine1 [root@handson5-docker ~]# docker run -d --name redmine3 -p 00 : 000 redmine

a3e3319a00d87cc9353d71406104eb245df45f69546a2280d8b0e3384342f9c8

[root@handson5-docker ~]# docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a3e3319a00d8 redmine "/docker-entrypoint.s" seconds ago Up seconds 0.0.0.0: 00 -> 000/tcp redmine3

0a9792796e0 redmine "/docker-entrypoint.s" seconds ago Up seconds 0.0.0.0: 00 -> 000/tcp redmine2 c5fb36a41 redmine "/docker-entrypoint.s" seconds ago Up seconds 0.0.0.0: 000-> 000/tcp redmine1 redmine 起動

ー 3000 ン ー 3000 関連付 い

redmine 起動

ー 3001 ン ー 3000 関連付 い

redmine 起動

ー 3002 ン ー 3000 関連付 い

(55)

同一設定のサービ の複数起動 ー フォワー

 先ほ 起動 ン redmine

 ン ン handson5-docker 割 当 Floating IP 以下 ${FIP} 表記

o

 http://${FIP}:3000/login , http://${FIP}:3001/login , http://${FIP}:3002/login

o 起動 少 時間 接続時 場合 少 待 再度

 ー ン redmine 成功

o 環境 独立性 確 環境 後 適当 操作 行 redmine

登録 い

o admin/admin 行い

(56)

同一設定のサービ の複数起動 ー フォワー

 同 ー 8080, 8081, 8082 ー ワー う Jenkins

起動

o Jenkins 入手 起動 動作 う 構築 配布

 起動 ー い

o 先:http://${FIP}:8080 , http://${FIP}:8081 , http://${FIP}:8082

 Jenkins ワー 設定 い

56

[root@handson5-docker ~]# docker run -d --name jenkins1 -p 8080:8080 -p 50000:50000 jenkins 3aa7643fc947848a2027fd7d3fbd8c2594e5267c4f001ad2f23459156f945414

[root@handson5-docker ~]# docker run -d --name jenkins2 -p 8081:8080 -p 50001:50000 jenkins 8de44e94075264fc438ec19ff34bb548806939d4c4806419d3183b0130998784

[root@handson5-docker ~]# docker run -d --name jenkins3 -p 8082:8080 -p 50002:50000 jenkins 06339bc45b27a10149eab023185b8f656319a35b3863944ae75a35e7be617a29

[root@handson5-docker ~]# docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 06339bc45b27 jenkins /bin/tini -- /usr/lo 4 seconds ago Up 2 seconds 0.0.0.0:8082->8080/tcp, 0.0.0.0:50002->50000/tcp jenkins3 8de44e940752 jenkins "/bin/tini -- /usr/lo" 10 seconds ago Up 7 seconds 0.0.0.0:8081->8080/tcp, 0.0.0.0:50001->50000/tcp jenkins2 3aa7643fc947 jenkins "/bin/tini -- /usr/lo" 13 seconds ago Up 13 seconds 0.0.0.0:8080->8080/tcp, 0.0.0.0:50000->50000/tcp jenkins1 ad3f8be6111d redmine "/docker-entrypoint.s" About a minute ago Up About a minute 0.0.0.0:3002->3000/tcp redmine3 bd36626fb407 redmine "/docker-entrypoint.s" About a minute ago Up About a minute 0.0.0.0:3001->3000/tcp redmine2 4fe288a688e9 redmine "/docker-entrypoint.s" About a minute ago Up About a minute 0.0.0.0:3000->3000/tcp redmine1 1 目 jenkins ン 起動

目 jenkins ン 起動

目 jenkins ン 起動

(57)

同一設定のサービ の複数起動 ー フォワー

 同一 内 全 同 設定 複数起動 い 確

[root@handson5-docker ~]# docker exec -it redmine1 /bin/bash root@4fe288a688e9:/usr/src/redmine# ps -ef

UID PID PPID C STIME TTY TIME CMD

redmine 0 0 0 :0 ? 00:00:0 /usr/local/bin/ruby bin/rails server -b 0.0.0.0 root 0 0 : ? 00:00:00 /bin/bash

root 0 0 : ? 00:00:00 ps -ef root@4fe288a688e9:/usr/src/redmine# exit

[root@handson5-docker ~]# docker exec -it jenkins1 /bin/bash jenkins@3aa7643fc947:/$ ps -ef

UID PID PPID C STIME TTY TIME CMD

jenkins 0 0 0 : 0 ? 00:00:00 /bin/tini -- /usr/local/bin/jenkins.sh jenkins 0 : 0 ? 00:00: java -jar /usr/share/jenkins/jenkins.war jenkins 0 0 : ? 00:00:00 /bin/bash

jenkins 0 0 : ? 00:00:00 ps -ef jenkins@3aa7643fc947:/$ exit

[root@handson5-docker ~]# ps -ef | grep bin/rails

polkitd 0 0 :0 ? 00:00:0 /usr/local/bin/ruby bin/rails server -b 0.0.0.0 polkitd 0 0 :0 ? 00:00:0 /usr/local/bin/ruby bin/rails server -b 0.0.0.0 polkitd 0 0 :0 ? 00:00:0 /usr/local/bin/ruby bin/rails server -b 0.0.0.0 root 0 : pts/0 00:00:00 grep --color=auto bin/rails

[root@handson5-docker ~]# ps -ef | grep jenkins.war

centos : 0 ? 00:00: java -jar /usr/share/jenkins/jenkins.war centos : 0 ? 00:00: java -jar /usr/share/jenkins/jenkins.war centos 0 : 0 ? 00:00: java -jar /usr/share/jenkins/jenkins.war

0 : 0 pts/0 00:00:00 grep --color=auto jenkins.war

起動済 ン /bin/bash 起動 接続

ン 内 最低限 起動

い 確認

Jenkins側 確認

確認

内 起動 確認 名前空間 分離

完全 同一 設定 持 可能 複数起動

(58)

同一設定のサービ の複数起動 ー フォワー

 各 ッ ワー ー ー 確認

o /proc 情報 確認

o 分離 確認

58

[root@handson5-docker ~]# ps -ef | grep bin/rails

polkitd 0 0 :0 ? 00:00:0 /usr/local/bin/ruby bin/rails server -b 0.0.0.0 polkitd 0 0 :0 ? 00:00:0 /usr/local/bin/ruby bin/rails server -b 0.0.0.0 polkitd 0 0 :0 ? 00:00:0 /usr/local/bin/ruby bin/rails server -b 0.0.0.0 root 0 : pts/0 00:00:00 grep --color=auto bin/rails

[root@handson5-docker ~]# ps -ef | grep jenkins.war

centos : 0 ? 00:00: java -jar /usr/share/jenkins/jenkins.war centos : 0 ? 00:00: java -jar /usr/share/jenkins/jenkins.war centos 0 : 0 ? 00:00: java -jar /usr/share/jenkins/jenkins.war root 0 : 0 pts/0 00:00:00 grep --color=auto jenkins.war

[root@handson5-docker ~]# ls -l /proc/{1,$$,ɰɮɰɱ,ɰɮɶɳ,ɰɯɳɱ,ɰɲɰɶ,ɰɳɮɵ,ɰɴɮɯ}/ns/net lrwxrwxrwx. 1 root root 0 4 15 15:22 /proc/1/ns/net -> net:[4026531956] lrwxrwxrwx. 1 root root 0 4 15 15:20 /proc/2145/ns/net -> net:[4026531956] lrwxrwxrwx. 1 polkitd ssh_keys 0 4 15 15:08 /proc/ /ns/net -> net:[4026532191] lrwxrwxrwx. 1 polkitd ssh_keys 0 4 15 15:26 /proc/ /ns/net -> net:[4026532296] lrwxrwxrwx. 1 polkitd ssh_keys 0 4 15 15:26 /proc/ /ns/net -> net:[4026532396] lrwxrwxrwx. 1 centos centos 0 4 15 15:27 /proc/ /ns/net -> net:[4026532496] lrwxrwxrwx. 1 centos centos 0 4 15 15:29 /proc/ /ns/net -> net:[4026532596] lrwxrwxrwx. 1 centos centos 0 4 15 15:29 /proc/ /ns/net -> net:[4026532696]

ン 内 起動 ID 調

/proc 以下 起動 関連 様々 情報

参照 状態 格納 特殊

ン い

中 ッ ワー ー

ー 関 情報 一覧 表示 い

PID 1 $$ 上 通常起動

い 同 ー ー

属 い 確認

$$ 現在起動 bash PID 置換

別 ン 他内 稼働 い

ー ー 識別情報 全 異

い 確認

(59)

同一設定のサービ の複数起動 ー フォワー

 動作確認 次 演習 備え ン

削除

[root@handson5-docker ~]# docker stop redmine1 redmine2 redmine3 jenkins1 jenkins2 jenkins3 redmine1

redmine2 redmine3 jenkins1 jenkins2 jenkins3

[root@handson5-docker ~]# docker rm redmine1 redmine2 redmine3 jenkins1 jenkins2 jenkins3 redmine1

redmine2 redmine3 jenkins1 jenkins2 jenkins3

[root@handson5-docker ~]# docker ps -a

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 一部 ン 操作 一括 行う 可能

全 ン 削除

(60)

ファイ の永続化

 ン 起動 後 ン 内 作成 ン 破棄 同時 削除 い

 演習 ン ッ ン 永続化 行い

o ッ ン 2 方法 あ 1 既 作成 ッ ン

方法 う1 Docker 自動管理 領域 ン ッ ン 方法

o 両方 方法 ッ ン 行い

60

[root@handson5-docker ~]# mkdir -p /root/docker

[root@handson5-docker ~]# chcon -Rt svirt_sandbox_file_t /root/docker

[root@handson5-docker ~]# docker run -d --name vol-1 \

-v /mnt/docker-host-vol \

-v /root/docker:/mnt/docker-host-fs \ centos:7 /sbin/init

60cc0efbe50bb5500c8d0bf6750b99190f32d79cbb4fa2e95f469f09e720ae3e

[root@handson5-docker ~]# docker run -d --name vol-2 \ --volumes-from vol-1 \ centos:7 /sbin/init

24432778be09a0dde08287c79f6f66713ca713786b31afe4cb0ae275adb0568a

[root@handson5-docker ~]# docker ps -a

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 24432778be09 centos:7 "/sbin/init" 2 minutes ago Up 2 minutes vol-2 60cc0efbe50b centos:7 "/sbin/init" 3 minutes ago Up 2 minutes vol-1

ン 共有 作成

SELinux 権限 与え い

SELinux Linux 機能

範囲 や

ッ ワー 機能等 ソー ー ー

制限 予期 い 等

防止 機能

1 2 接続

起動

1 Docker 管理 自動 /mnt/docker-host-vol 接続

う1 Docker 上 /root/docker /mnt/docker-host-fs 接続

2 1 vol-1

同 設定 ン 起動 い

(61)

ファイ の永続化

 作成 ン 情報 中 ー 関 部分 確認 い

o docker inspect 設定 確認

[root@handson5-docker ~]# docker inspect vol-1 | python -m json.tool | less 省略

"Mounts": [ {

"Destination": "/mnt/docker-host-fs",

"Mode": "",

"RW": true,

"Source": "/root/docker" },

{

"Destination": "/mnt/docker-host-vol",

"Driver": "local",

"Mode": "",

"Name": "30a93be94994feaa3a30887fd27a5e368af37e26251cda1a2db692b27a1a6078",

"RW": true,

"Source": "/var/lib/docker/volumes/30a93be94994feaa3a30887fd27a5e368af37e26251cda1a2db692b27a1a6078/_data" }

],

[root@handson5-docker ~]# docker inspect vol-2 | python -m json.tool | less 省略

"Mounts": [ {

"Destination": "/mnt/docker-host-fs",

"Mode": "",

"RW": true,

"Source": "/root/docker" },

{

"Destination": "/mnt/docker-host-vol",

"Driver": "local",

"Mode": "",

"Name": "30a93be94994feaa3a30887fd27a5e368af37e26251cda1a2db692b27a1a6078",

"RW": true,

"Source": "/var/lib/docker/volumes/30a93be94994feaa3a30887fd27a5e368af37e26251cda1a2db692b27a1a6078/_data" }

情報 参照

参照 終了 q キー 押下 い

ン 起動時 指定

ッ ン 情報 確認

Source 指定

Docker

自動作成い

vol-1 同様 設定 行う う 設定 い

全 同 設定 確認

(62)

ファイ の永続化

 ッ ン 書 込

o 書 込 ッ ン

o 次項 上 別 vol-2 う 参照 確認

62

[root@handson5-docker ~]# docker exec -it vol-1 /bin/ls -l /mnt total 0

drwxr-xr-x. 2 root root 17 Apr 15 11:59 docker-host-fs drwxr-xr-x. 2 root root 6 Apr 16 00:39 docker-host-vol

[root@handson5-docker ~]# docker exec -it vol-2 /bin/ls -l /mnt total 0

drwxr-xr-x. 2 root root 17 Apr 15 11:59 docker-host-fs drwxr-xr-x. 2 root root 6 Apr 16 00:39 docker-host-vol

[root@handson5-docker ~]# docker exec -it vol-1 /bin/bash

[root@60cc0efbe50b /]# echo "this is your_name's file" >> /mnt/docker-host-fs/file_on_fs.txt [root@60cc0efbe50b /]# echo "this is your_name's file" >> /mnt/docker-host-vol/file_on_vol.txt

[root@60cc0efbe50b /]# cat /mnt/docker-host-fs/file_on_fs.txt this is your_name's file

[root@60cc0efbe50b /]# cat /mnt/docker-host-vol/file_on_vol.txt this is your_name's file

[root@60cc0efbe50b /]# exit [root@handson5-docker ~]#

vol-1 ッ ン 確認

vol-2 ッ ン 確認

vol-1 同 内容 確認

vol-1 書 込

your_name 部分 自分 名前 書 換え い

書 込 い 確認

(63)

ファイ の永続化

 書 込 ン vol-2 Docker 上 確認

[root@handson5-docker ~]# docker exec -it vol-2 /bin/cat /mnt/docker-host-fs/file_on_fs.txt this is your_name's file

[root@handson5-docker ~]# docker exec -it vol-2 /bin/cat /mnt/docker-host-vol/file_on_vol.txt this is your_name's file

[root@handson5-docker ~]# cat /root/docker/file_on_fs.txt this is your_name's file

[root@handson5-docker ~]# docker inspect vol-1 | python -m json.tool | less

省略

"Mounts": [ {

"Destination": "/mnt/docker-host-fs",

"Mode": "",

"RW": true,

"Source": "/root/docker" },

{

"Destination": "/mnt/docker-host-vol",

"Driver": "local",

"Mode": "",

"Name": "30a93be94994feaa3a30887fd27a5e368af37e26251cda1a2db692b27a1a6078",

"RW": true,

"Source": "/var/lib/docker/volumes/30a93be94994feaa3a30887fd27a5e368af37e26251cda1a2db692b27a1a6078/_data" }

],

[root@handson5-docker ~]# cat /var/lib/docker/volumes/30a93be94 省略 b27a1a6078/_data/file_on_vol.txt this is your_name's file

vol-2 2

確認 同

内容 確認

Docker 確認 同 内容 確認

2 環境 docker

inspect 確認 指定

Docker 確認

(64)

ファイ の永続化

 書 込 ン vol-2 Docker 上 確認

64

[root@handson5-docker ~]# docker stop vol-1 [root@handson5-docker ~]# docker rm vol-1

[root@handson5-docker ~]# docker exec -it vol-2 /bin/cat /mnt/docker-host-fs/file_on_fs.txt this is your_name's file

[root@handson5-docker ~]# docker exec -it vol-2 /bin/cat /mnt/docker-host-vol/file_on_vol.txt this is your_name's file

[root@handson5-docker ~]# cat /root/docker/file_on_fs.txt this is your_name's file

[root@handson5-docker ~]# cat /var/lib/docker/volumes/30a93be94 省略 27a1a6078/_data/file_on_vol.txt this is your_name's file

[root@handson5-docker ~]# docker stop vol-2 [root@handson5-docker ~]# docker rm vol-2

[root@handson5-docker ~]# cat /root/docker/file_on_fs.txt this is your_name's file

[root@handson5-docker ~]# cat /var/lib/docker/volumes/30a93be94 省略 b27a1a6078/_data/file_on_vol.txt this is your_name's file

vol-1 停止 削除

vol-1 削除 vol-2

参照 行 え

同様 Docker 参照

vol-2 削除 利用

ン 全 削除

全 ン 削除

残 い 事 確認

(65)

イメー の イフサイ 管理

 起動 ン 各種変更 行い ー 更新

o 起動 内 httpd

[root@handson5-docker ~]# docker run -d --name my-httpd centos:7 /sbin/init 7f526cacc315db5648c84faa13086364347089e88da28ed18830de85e6e7248d

[root@handson5-docker ~]# docker exec -it my-httpd /bin/bash

[root@7f526cacc315 /]# echo "xxx.xxx.xxx.xxx reposerver" >> /etc/hosts [root@7f526cacc315 /]# rm -Rf /etc/yum.repos.d/*

[root@7f526cacc315 /]# curl -o /etc/yum.repos.d/edubase.repo reposerver/repo/edubase.repo [root@7f526cacc315 /]# yum clean all

Loaded plugins: fastestmirror, ovl

Cleaning repos: base epel extras openstack updates Cleaning up everything

[root@7f526cacc315 /]# yum repolist Loaded plugins: fastestmirror, ovl

省略

repo id repo name status

base CentOS-7 - Base 9363

epel Extra Packages for Enterprise Linux 7 - x86_64 10936

extras CentOS-7 - Extras 435

openstack OpenStack Repository 1673

updates CentOS-7 - Updates 393

repolist: 22800

[root@7f526cacc315 /]# yum install -y httpd [root@7f526cacc315 /]# exit

CentOS7 起動

/sbin/init 起動 ー ン -d 起動

bash 起動 ンソー 接続

演習用 ー ー 接続 う

ン 内 設定 変更

xxx 部分 reposerver IP 置

換え い

ン 内 httpd ン ー

(66)

イメー の イフサイ 管理

 変更 加え ン 停止 ー 登録

 ー 化 変更 加え ン 何度 起動 う

o httpd 使え httpd 起動

66

[root@handson5-docker ~]# docker ps -a

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

7f526cacc315 centos:7 "/sbin/init" 3 minutes ago Up 3 minutes my-httpd [root@handson5-docker ~]# docker stop my-httpd

my-httpd

[root@handson5-docker ~]# docker ps -a

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

7f526cacc315 centos:7 "/sbin/init" 3 minutes ago Exited (137) 10 seconds ago my-httpd [root@handson5-docker ~]# docker commit my-httpd my-httpd:v1

29b797c8dfd9a4a96877d361e3c25308d3cc85d5aab997d4def3c2b5d215ca3b [root@handson5-docker ~]# docker images

REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE

my-httpd v1 29b797c8dfd9 6 seconds ago 327.8 MB

docker.io/irixjp/ansible 2.0.1.0_01 543d1f06142a 12 months ago 557.8 MB

docker.io/jenkins latest 5f5049ed8eb5 12 months ago 709.1 MB

docker.io/redmine latest efbf53b9ce8a 13 months ago 587.3 MB

docker.io/centos 6 6e93f19d1d37 13 months ago 228.9 MB

docker.io/centos 7 bb3d629a7cbc 13 months ago 196.6 MB

docker.io/enakai00/eplite ver1.0 5a25f68ed3c5 16 months ago 729.2 MB docker.io/enakai00/epmysql ver1.0 8a63eb16bbca 16 months ago 339.3 MB [root@handson5-docker ~]# docker rm my-httpd

my-httpd

ー 化 一度 ン 停止

ン ー 作成

識別子 名前 my-httpd v1 設定

新 い ー

登録 い

ン 削除

(67)

イメー の イフサイ 管理

 新 登録 ー ン 起動

o httpd ン ー 済 httpd 起動

o 起動 httpd 直接起動 ー 8080

ー 80 ー ワー い

[root@handson5-docker ~]# docker run -d --name my-httpd -p 8080:80 my-httpd:v1 /sbin/httpd -DFOREGROUND 7314a46368f6e3760cdd8c0f8c77526d8f6abcbd309dbc24bf76cf90d66222ae

[root@handson5-docker ~]# docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

7314a46368f6 my-httpd:v1 "/sbin/httpd -DFOREGR" 3 seconds ago Up 2 seconds 0.0.0.0:8080->80/tcp my-httpd httpd 起動 ー ン -d

作成 合わ 8080→80 ー ワー 設定 い

Docker ${FIP}

時 ー 8080 指定 い

httpd 起動 Apache 初期画面 表示

(68)

イメー の イフサイ 管理

 更 ン 変更 加え ー ン2 ー 保存

o index.html 配置

o 配置 v2 保存

68

[root@handson5-docker ~]# docker exec -it my-httpd /bin/bash

[root@7314a46368f6 /]# echo "this is your_name's page" >> /var/www/html/index.html [root@7314a46368f6 /]# exit

[root@handson5-docker ~]# docker stop my-httpd my-httpd

[root@handson5-docker ~]# docker commit my-httpd my-httpd:v2 e4c71f8e4750743ae76fa39fa92e48a769f031b8ab24bf5771c52176d5d9f8a3 [root@handson5-docker ~]# docker images

REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE

my-httpd v2 e4c71f8e4750 4 seconds ago 327.8 MB

my-httpd v1 29b797c8dfd9 About an hour ago 327.8 MB

docker.io/irixjp/ansible 2.0.1.0_01 543d1f06142a 12 months ago 557.8 MB

docker.io/jenkins latest 5f5049ed8eb5 12 months ago 709.1 MB

docker.io/redmine latest efbf53b9ce8a 13 months ago 587.3 MB

省略

[root@handson5-docker ~]# docker rm my-httpd my-httpd

[root@handson5-docker ~]# docker ps -a

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

起動中 ン 接続

httpd 配置

your_name 部分 自分 名前 置 換え い

ン 停止 v2 ー 保

新 い ー

登録 い

ン 削除

参照

関連したドキュメント

Appendix 3 Data Elements to Be Filed (2) Ocean(Master) Bill of Lading on Cargo InfomationHouse Bill of Lading on Cargo Infomation 11Vessel Code (Call Sign)Vessel Code (Call

Therefore, after the foreign trading vessel departs from a port of loading, the shipping company, who files at the port of loading in the Pre-departure filing (the new rules), carries

2.集熱器・蓄熱槽集中 一括徴収 各住戸支払 一括徴収 3.集熱器・補助熱源・蓄熱槽集中 一括徴収 一括徴収 一括徴収. (参考)個別設置方式 各住戸支払

最近の電装工事における作業環境は、電気機器及び電線布設量の増加により複雑化して

4) Maximum Annual Rate: 26.8 fl oz/A/year (equivalent to 0.262 lb ai pydifl umetofen and 0.438 lb ai fl udioxonil) a. DO NOT apply more than 0.268 lb ai/A/year of

Continue applications through season on a 7- 10-day interval if conditions remain favorable for disease development, following the resistance management guidelines. Apply

Do not connect an irrigation system (including greenhouse systems) used for pesticide application to a public water system unless the pesticide label- prescribed safety devices

安全第一 福島第一安全第一 福島第一 安全 第一 福島第一. 安全第一 福島第一安全第一