SlideShare une entreprise Scribd logo
1  sur  32
Télécharger pour lire hors ligne
●
●
●
●
●
●
● ✔
● ✔
● ✘
●
VM
●
●
●
● Docker
● Go
● 1 1
● LXC libcontainer
●
● root docker pull
● CentOS/Rocket
● Docker
●
● systemd-nspawn
● systemd
● Rocket
● MINCS
● shell script
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
$ ll /proc/$$/ns
0
lrwxrwxrwx. 1 takei takei 0 10 17 20:57 ipc -> ipc:[4026531839]
lrwxrwxrwx. 1 takei takei 0 10 17 20:57 mnt -> mnt:[4026531840]
lrwxrwxrwx. 1 takei takei 0 10 17 20:57 net -> net:[4026531992]
lrwxrwxrwx. 1 takei takei 0 10 17 20:57 pid -> pid:[4026531836]
●
●
$ readlink /proc/$$/ns/mnt # mount
mnt:[4026531840]
$ sudo unshare --mount /bin/bash # mount
# readlink /proc/$$/ns/mnt # mount
mnt:[4026532249]
# mkdir mnt; mount -t tmpfs tmpfs mnt
# mount #
# exit
●
●
●
$ mkdir src dest src/{master,slave}
# mount --bind src dest # src dest bind
# mount --make-slave dest # master slave
# mount -t tmpfs tmpfs src/master # (src)
# mount -t tmpfs tmpfs dest/slave # (dest)
$ mount
tmpfs on /home/alice/src/master type tmpfs (rw,relatime,seclabel)
●
●
●
●
●
●
●
●
●
●
$ sudo unshare --mount /bin/bash # mount
# mkdir mnt
# mount --make-private / #
# mount -t tmpfs tmpfs mnt
# mount --make-shared / #
# mount #
# exit
$ mount #
●
●
●
●
●
●
●
●
●
●
$ hostname
ip-172-31-13-102.ap-northeast-1.compute.internal
$ sudo unshare --uts
# hostname wonderland
# hostname
wonderland
# logout
$ hostname
ip-172-31-13-102.ap-northeast-1.compute.internal
●
●
●
$ sudo ip netns add test # test netns
$ sudo ip netns list #
test
$ sudo ip netns exec test /bin/bash # test
# readlink /proc/$$/ns/net # netns
net:[4026532219]
# ls -li /var/run/netns/test # /var/run/netns
4026532219 -r--r--r--. 1 root root 0 Oct 18 03:02 /run/netns/test
# ip addr # lo
●
●
$ sudo ip link add name master type veth peer name slave # veth
$ sudo ip addr #
6: slave: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether 3a:64:e8:80:03:5f brd ff:ff:ff:ff:ff:ff
7: master: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether 86:cf:cc:26:74:e4 brd ff:ff:ff:ff:ff:ff
$ sudo ip link set slave netns test # netns test
$ sudo ip addr #
7: master: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether 86:cf:cc:26:74:e4 brd ff:ff:ff:ff:ff:ff
$ sudo ip netns exec test ip addr
6: slave: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether 3a:64:e8:80:03:5f brd ff:ff:ff:ff:ff:ff
● eth (veth)
● 2. IP &
$ sudo ip addr add 192.168.50.101/24 dev master # master IP
$ sudo ip link set dev master up #
$ sudo ip netns exec test /bin/bash # bash
# ip addr add 192.168.50.102/24 dev slave # slave IP
# ip link set dev slave up #
# ping 192.168.50.101 -c1 #
PING 192.168.50.101 (192.168.50.101) 56(84) bytes of data.
64 bytes from 192.168.50.101: icmp_seq=1 ttl=64 time=0.047 ms
# exit
$ ping 192.168.50.102 -c1
net - : veth
● eth (veth)
● 3. IP &
$ sudo ip netns exec test /bin/bash
# ip route add default via 192.168.50.101 dev slave # default gw
# ip route
default via 192.168.50.101 dev slave
192.168.50.0/24 dev slave proto kernel scope link src 192.168.50.102
# exit
$ # IP
$ sudo iptables -t nat -A POSTROUTING -s 192.168.50.0/24 -o eth0 -j MASQUERADE
$ sudo ip netns exec test /bin/bash
# ping 8.8.8.8 -c1 #
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=55 time=2.18 ms
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
mkdir new-root
sudo yum -y --releasever=7Server --installroot=${PWD}/new-root install 
@Core @Base redhat-release-server vim-enhanced
●
●
●
●
●
$ sudo unshare -m -p -f /bin/bash # pid/mnt
# mount --make-rprivate / # off
# mount -o loop /root.img /mnt/new-root/ # root
# cd /mnt/new-root/
# mkdir .old # root
# pivot_root . .old # pivot!
●
●
●
●
●
●
●
●
$ mkdir upper work #
$ sudo mount -t overlay 
-o lowerdir=/,upperdir=upper,workdir=work overlayfs new-root
$ touch /home/alice/file1 new-root/home/alice/file2
$ ls -l new-root/home/alice/file* #
-rw-rw-r--. 1 alice alice 0 Oct 18 12:30 new-root/home/alice/file1
-rw-rw-r--. 1 alice alice 0 Oct 18 12:30 new-root/home/alice/file2
$ rm new-root/home/alice/file1 #
$ ll upper/home/alice/file* # upper
●
●
●
●
●
●
● Docker
● 1. loop back dm-thin pool
● /var/lib/docker/devicemapper/devicemapper/{,meta}data
$ sudo systemctl start docker # docker
$ losetup # loop pool
NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE
/dev/loop0 0 0 1 0 /var/lib/docker/devicemapper/devicemapper/data
/dev/loop1 0 0 1 0 /var/lib/docker/devicemapper/devicemapper/metadata
$ sudo ls -hl /var/lib/docker/devicemapper/devicemapper/ # 100G 2G ( )
total 4.5G
-rw-------. 1 root root 100G Oct 19 04:54 data
-rw-------. 1 root root 2.0G Oct 19 04:56 metadata
●
●
●
●
$ sudo du -h /var/lib/docker/devicemapper/devicemapper/data
4.4G/var/lib/docker/devicemapper/devicemapper/data
$ sudo ls -lh /var/lib/docker/devicemapper/devicemapper/data
-rw-------. 1 root root 100G Oct 19 04:54 /var/lib/docker/devicemapper/devicemapper/data
$ fallocate -o 9223372036854775807 -l 1 huge # fallocate
$ ls -lh huge; du -h huge # 8EB( )!!
-rw-r--r--. 1 alice alice 8.0E Oct 19 05:10 huge
● 2.
● 10G (RHEL7 default)
$ docker run -d centos:centos7 /sbin/init #
$ docker ps # ID
CONTAINER ID IMAGE COMMAND ...
b90ed5b981ae centos:centos7 "/sbin/init" ...
$ lsblk #
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 30G 0 disk
─xvda1 202:1 0 1M 0 part
└─xvda2 202:2 0 30G 0 part /
loop0 7:0 0 100G 0 loop
└─docker-202:2-62765-pool 253:0 0 100G 0 dm
└─docker-202:2-62765-b90ed5b981ae9d06...ee67 253:1 0 10G 0 dm
loop1 7:1 0 2G 0 loop
●
$ # id
$ sudo jq . /var/lib/docker/repositories-devicemapper
{
"Repositories": {
"test": { "latest": "a02698bf3...e5c42b" }
},
"ConfirmDefPush": true
}
$ # dm-thin
$ sudo jq . /var/lib/docker/devicemapper/metadata/a02698bf3...e5c42b
{
"device_id": 352,
"size": 10737418240,
"transaction_id": 582,
●
$ # device_id size
$ sudo jq . /var/lib/docker/devicemapper/metadata/a02698bf...5c42b
... "device_id": 352, "size": 10737418240, ...
$ #
$ lsblk
loop0
└─docker-202:2-62765-pool
$ # dm
$ sudo dmsetup create dockervol 
--table "0 $((10737418240 / 512)) thin /dev/mapper/docker-202:2-62765-pool 352"
$ # dm
$ ll /dev/mapper/dockervol
lrwxrwxrwx. 1 root root 7 Oct 19 06:10 /dev/mapper/dockervol -> ../dm-3
● ( ) docker
30
$ ll mnt/ #
total 24
-rw-------. 1 root root 64 Aug 26 23:08 id
drwx------. 2 root root 16384 Aug 26 22:58 lost+found
$ ll mnt/rootfs/ # docker (OS)
total 64
lrwxrwxrwx. 1 root root 7 Jun 18 08:34 bin -> usr/bin
drwxr-xr-x. 3 root root 4096 Oct 18 12:56 boot
:
$ sudo cat mnt/id # id id
f1b10cd842498c23d206ee0cbeaa9de8d2ae09ff3c7af2723a9e337a6965d639
$ docker history test:latest
IMAGE CREATED CREATED BY ...
a02698bf3120 17 hours ago /bin/sh -c yum install -y httpd
a6673f7926d7 7 weeks ago /bin/sh -c #(nop) MAINTAINER TAKEI Yuya <take
●
●
●
●
●
●
●
●
●
●
●
●
●
●
● TenForward - MINCS (1)
● http://d.hatena.ne.jp/defiant/20150701/1435749116
●
●
●
●
●
●

Contenu connexe

Tendances

Tendances (18)

От sysV к systemd
От sysV к systemdОт sysV к systemd
От sysV к systemd
 
3 manual installation of open vpn
3 manual installation of open vpn3 manual installation of open vpn
3 manual installation of open vpn
 
BlockChain implementation by python
BlockChain implementation by pythonBlockChain implementation by python
BlockChain implementation by python
 
Great Hiroshima with Python 170830
Great Hiroshima with Python 170830Great Hiroshima with Python 170830
Great Hiroshima with Python 170830
 
Workflow && t1k
Workflow && t1kWorkflow && t1k
Workflow && t1k
 
Beyond Golden Containers: Complementing Docker with Puppet
Beyond Golden Containers: Complementing Docker with PuppetBeyond Golden Containers: Complementing Docker with Puppet
Beyond Golden Containers: Complementing Docker with Puppet
 
Build your own private openstack cloud
Build your own private openstack cloudBuild your own private openstack cloud
Build your own private openstack cloud
 
Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...
Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...
Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...
 
使用 CLI 管理 OpenStack 平台
使用 CLI 管理 OpenStack 平台使用 CLI 管理 OpenStack 平台
使用 CLI 管理 OpenStack 平台
 
Docker 基本概念與指令操作
Docker  基本概念與指令操作Docker  基本概念與指令操作
Docker 基本概念與指令操作
 
Redmine on amazon ec2
Redmine on amazon ec2Redmine on amazon ec2
Redmine on amazon ec2
 
Magento 2 Seminar - Miguel Balparda - M2 with PHP 7 and Varnish
Magento 2 Seminar - Miguel Balparda - M2 with PHP 7 and VarnishMagento 2 Seminar - Miguel Balparda - M2 with PHP 7 and Varnish
Magento 2 Seminar - Miguel Balparda - M2 with PHP 7 and Varnish
 
Ubic
UbicUbic
Ubic
 
R-House (LSRC)
R-House (LSRC)R-House (LSRC)
R-House (LSRC)
 
Vm ware fuzzing - defcon russia 20
Vm ware fuzzing  - defcon russia 20Vm ware fuzzing  - defcon russia 20
Vm ware fuzzing - defcon russia 20
 
NAS Botnet Revealed - Mining Bitcoin
NAS Botnet Revealed - Mining Bitcoin NAS Botnet Revealed - Mining Bitcoin
NAS Botnet Revealed - Mining Bitcoin
 
MyAWR another mysql awr
MyAWR another mysql awrMyAWR another mysql awr
MyAWR another mysql awr
 
Inspector - Node.js : Notes
Inspector - Node.js : NotesInspector - Node.js : Notes
Inspector - Node.js : Notes
 

Similaire à PFIセミナー資料 H27.10.22

glance replicator
glance replicatorglance replicator
glance replicator
irix_jp
 

Similaire à PFIセミナー資料 H27.10.22 (20)

Reverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande ModemReverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande Modem
 
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
 
Openstack 101
Openstack 101Openstack 101
Openstack 101
 
Docker practice
Docker practiceDocker practice
Docker practice
 
Docker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in PragueDocker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in Prague
 
A little systemtap
A little systemtapA little systemtap
A little systemtap
 
Ubic-public
Ubic-publicUbic-public
Ubic-public
 
DCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker Captains
 
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation CenterDUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
 
Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021
 
Docker command
Docker commandDocker command
Docker command
 
Multipath
MultipathMultipath
Multipath
 
Defcon CTF quals
Defcon CTF qualsDefcon CTF quals
Defcon CTF quals
 
glance replicator
glance replicatorglance replicator
glance replicator
 
Qt native built for raspberry zero
Qt native built for  raspberry zeroQt native built for  raspberry zero
Qt native built for raspberry zero
 
Docker, the Future of DevOps
Docker, the Future of DevOpsDocker, the Future of DevOps
Docker, the Future of DevOps
 
Velocity 2011 - Our first DDoS attack
Velocity 2011 - Our first DDoS attackVelocity 2011 - Our first DDoS attack
Velocity 2011 - Our first DDoS attack
 
Linux: LVM
Linux: LVMLinux: LVM
Linux: LVM
 
Haproxy - zastosowania
Haproxy - zastosowaniaHaproxy - zastosowania
Haproxy - zastosowania
 
x86_64 Hardware Deep dive
x86_64 Hardware Deep divex86_64 Hardware Deep dive
x86_64 Hardware Deep dive
 

Dernier

Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
UXDXConf
 

Dernier (20)

AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 

PFIセミナー資料 H27.10.22

  • 1.
  • 4. ● ● ● ● Docker ● Go ● 1 1 ● LXC libcontainer ● ● root docker pull
  • 5. ● CentOS/Rocket ● Docker ● ● systemd-nspawn ● systemd ● Rocket ● MINCS ● shell script ●
  • 8. ● ● ● ● ● $ ll /proc/$$/ns 0 lrwxrwxrwx. 1 takei takei 0 10 17 20:57 ipc -> ipc:[4026531839] lrwxrwxrwx. 1 takei takei 0 10 17 20:57 mnt -> mnt:[4026531840] lrwxrwxrwx. 1 takei takei 0 10 17 20:57 net -> net:[4026531992] lrwxrwxrwx. 1 takei takei 0 10 17 20:57 pid -> pid:[4026531836]
  • 9. ● ● $ readlink /proc/$$/ns/mnt # mount mnt:[4026531840] $ sudo unshare --mount /bin/bash # mount # readlink /proc/$$/ns/mnt # mount mnt:[4026532249] # mkdir mnt; mount -t tmpfs tmpfs mnt # mount # # exit
  • 10. ● ● ● $ mkdir src dest src/{master,slave} # mount --bind src dest # src dest bind # mount --make-slave dest # master slave # mount -t tmpfs tmpfs src/master # (src) # mount -t tmpfs tmpfs dest/slave # (dest) $ mount tmpfs on /home/alice/src/master type tmpfs (rw,relatime,seclabel)
  • 12. ● ● $ sudo unshare --mount /bin/bash # mount # mkdir mnt # mount --make-private / # # mount -t tmpfs tmpfs mnt # mount --make-shared / # # mount # # exit $ mount #
  • 14. ● ● $ hostname ip-172-31-13-102.ap-northeast-1.compute.internal $ sudo unshare --uts # hostname wonderland # hostname wonderland # logout $ hostname ip-172-31-13-102.ap-northeast-1.compute.internal
  • 15. ● ● ● $ sudo ip netns add test # test netns $ sudo ip netns list # test $ sudo ip netns exec test /bin/bash # test # readlink /proc/$$/ns/net # netns net:[4026532219] # ls -li /var/run/netns/test # /var/run/netns 4026532219 -r--r--r--. 1 root root 0 Oct 18 03:02 /run/netns/test # ip addr # lo
  • 16. ● ● $ sudo ip link add name master type veth peer name slave # veth $ sudo ip addr # 6: slave: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000 link/ether 3a:64:e8:80:03:5f brd ff:ff:ff:ff:ff:ff 7: master: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000 link/ether 86:cf:cc:26:74:e4 brd ff:ff:ff:ff:ff:ff $ sudo ip link set slave netns test # netns test $ sudo ip addr # 7: master: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000 link/ether 86:cf:cc:26:74:e4 brd ff:ff:ff:ff:ff:ff $ sudo ip netns exec test ip addr 6: slave: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000 link/ether 3a:64:e8:80:03:5f brd ff:ff:ff:ff:ff:ff
  • 17. ● eth (veth) ● 2. IP & $ sudo ip addr add 192.168.50.101/24 dev master # master IP $ sudo ip link set dev master up # $ sudo ip netns exec test /bin/bash # bash # ip addr add 192.168.50.102/24 dev slave # slave IP # ip link set dev slave up # # ping 192.168.50.101 -c1 # PING 192.168.50.101 (192.168.50.101) 56(84) bytes of data. 64 bytes from 192.168.50.101: icmp_seq=1 ttl=64 time=0.047 ms # exit $ ping 192.168.50.102 -c1
  • 18. net - : veth ● eth (veth) ● 3. IP & $ sudo ip netns exec test /bin/bash # ip route add default via 192.168.50.101 dev slave # default gw # ip route default via 192.168.50.101 dev slave 192.168.50.0/24 dev slave proto kernel scope link src 192.168.50.102 # exit $ # IP $ sudo iptables -t nat -A POSTROUTING -s 192.168.50.0/24 -o eth0 -j MASQUERADE $ sudo ip netns exec test /bin/bash # ping 8.8.8.8 -c1 # PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data. 64 bytes from 8.8.8.8: icmp_seq=1 ttl=55 time=2.18 ms
  • 20. ● ● ● ● ● ● mkdir new-root sudo yum -y --releasever=7Server --installroot=${PWD}/new-root install @Core @Base redhat-release-server vim-enhanced
  • 21. ● ● ● ● ● $ sudo unshare -m -p -f /bin/bash # pid/mnt # mount --make-rprivate / # off # mount -o loop /root.img /mnt/new-root/ # root # cd /mnt/new-root/ # mkdir .old # root # pivot_root . .old # pivot!
  • 23. ● ● ● $ mkdir upper work # $ sudo mount -t overlay -o lowerdir=/,upperdir=upper,workdir=work overlayfs new-root $ touch /home/alice/file1 new-root/home/alice/file2 $ ls -l new-root/home/alice/file* # -rw-rw-r--. 1 alice alice 0 Oct 18 12:30 new-root/home/alice/file1 -rw-rw-r--. 1 alice alice 0 Oct 18 12:30 new-root/home/alice/file2 $ rm new-root/home/alice/file1 # $ ll upper/home/alice/file* # upper
  • 25. ● Docker ● 1. loop back dm-thin pool ● /var/lib/docker/devicemapper/devicemapper/{,meta}data $ sudo systemctl start docker # docker $ losetup # loop pool NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE /dev/loop0 0 0 1 0 /var/lib/docker/devicemapper/devicemapper/data /dev/loop1 0 0 1 0 /var/lib/docker/devicemapper/devicemapper/metadata $ sudo ls -hl /var/lib/docker/devicemapper/devicemapper/ # 100G 2G ( ) total 4.5G -rw-------. 1 root root 100G Oct 19 04:54 data -rw-------. 1 root root 2.0G Oct 19 04:56 metadata
  • 26. ● ● ● ● $ sudo du -h /var/lib/docker/devicemapper/devicemapper/data 4.4G/var/lib/docker/devicemapper/devicemapper/data $ sudo ls -lh /var/lib/docker/devicemapper/devicemapper/data -rw-------. 1 root root 100G Oct 19 04:54 /var/lib/docker/devicemapper/devicemapper/data $ fallocate -o 9223372036854775807 -l 1 huge # fallocate $ ls -lh huge; du -h huge # 8EB( )!! -rw-r--r--. 1 alice alice 8.0E Oct 19 05:10 huge
  • 27. ● 2. ● 10G (RHEL7 default) $ docker run -d centos:centos7 /sbin/init # $ docker ps # ID CONTAINER ID IMAGE COMMAND ... b90ed5b981ae centos:centos7 "/sbin/init" ... $ lsblk # NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT xvda 202:0 0 30G 0 disk ─xvda1 202:1 0 1M 0 part └─xvda2 202:2 0 30G 0 part / loop0 7:0 0 100G 0 loop └─docker-202:2-62765-pool 253:0 0 100G 0 dm └─docker-202:2-62765-b90ed5b981ae9d06...ee67 253:1 0 10G 0 dm loop1 7:1 0 2G 0 loop
  • 28. ● $ # id $ sudo jq . /var/lib/docker/repositories-devicemapper { "Repositories": { "test": { "latest": "a02698bf3...e5c42b" } }, "ConfirmDefPush": true } $ # dm-thin $ sudo jq . /var/lib/docker/devicemapper/metadata/a02698bf3...e5c42b { "device_id": 352, "size": 10737418240, "transaction_id": 582,
  • 29. ● $ # device_id size $ sudo jq . /var/lib/docker/devicemapper/metadata/a02698bf...5c42b ... "device_id": 352, "size": 10737418240, ... $ # $ lsblk loop0 └─docker-202:2-62765-pool $ # dm $ sudo dmsetup create dockervol --table "0 $((10737418240 / 512)) thin /dev/mapper/docker-202:2-62765-pool 352" $ # dm $ ll /dev/mapper/dockervol lrwxrwxrwx. 1 root root 7 Oct 19 06:10 /dev/mapper/dockervol -> ../dm-3
  • 30. ● ( ) docker 30 $ ll mnt/ # total 24 -rw-------. 1 root root 64 Aug 26 23:08 id drwx------. 2 root root 16384 Aug 26 22:58 lost+found $ ll mnt/rootfs/ # docker (OS) total 64 lrwxrwxrwx. 1 root root 7 Jun 18 08:34 bin -> usr/bin drwxr-xr-x. 3 root root 4096 Oct 18 12:56 boot : $ sudo cat mnt/id # id id f1b10cd842498c23d206ee0cbeaa9de8d2ae09ff3c7af2723a9e337a6965d639 $ docker history test:latest IMAGE CREATED CREATED BY ... a02698bf3120 17 hours ago /bin/sh -c yum install -y httpd a6673f7926d7 7 weeks ago /bin/sh -c #(nop) MAINTAINER TAKEI Yuya <take
  • 32. ● ● ● ● ● ● ● TenForward - MINCS (1) ● http://d.hatena.ne.jp/defiant/20150701/1435749116 ● ● ● ● ● ●