core@localhost ~ $ ifconfig
docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.17.42.1 netmask 255.255.0.0 broadcast 0.0.0.0
inet6 fe80::5484:7aff:fefe:9799 prefixlen 64 scopeid 0x20<link>
ether 56:84:7a:fe:97:99 txqueuelen 0 (Ethernet)
RX packets 268 bytes 12676 (12.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 72 bytes 5532 (5.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp0s17: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.38.101 netmask 255.255.255.0 broadcast 192.168.38.255
inet6 fe80::20c:29ff:fe74:6be9 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:74:6b:e9 txqueuelen 1000 (Ethernet)
RX packets 5057 bytes 540415 (527.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3835 bytes 390753 (381.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 18 base 0x1400
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 606 bytes 163904 (160.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 606 bytes 163904 (160.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
veth1d00: flags=67<UP,BROADCAST,RUNNING> mtu 1500
inet6 fe80::24e7:74ff:fee0:ec46 prefixlen 64 scopeid 0x20<link>
ether 26:e7:74:e0:ec:46 txqueuelen 1000 (Ethernet)
RX packets 32 bytes 2216 (2.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 21 bytes 1926 (1.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
core@localhost ~ $ ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s17: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
link/ether 00:0c:29:74:6b:e9 brd ff:ff:ff:ff:ff:ff
3: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT
link/ether 56:84:7a:fe:97:99 brd ff:ff:ff:ff:ff:ff
9: veth1d00: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master docker0 state UP mode DEFAULT qlen 1000
link/ether 26:e7:74:e0:ec:46 brd ff:ff:ff:ff:ff:ff
core@localhost ~ $ ethtool -S veth1d00
NIC statistics:
peer_ifindex: 8
core@localhost ~ $ docker run --rm -i busybox
ifconfig
eth0 Link encap:Ethernet HWaddr 36:25:76:05:39:DB
inet addr:172.17.0.4 Bcast:0.0.0.0 Mask:255.255.0.0
UP BROADCAST RUNNING MTU:1500 Metric:1
RX packets:21 errors:0 dropped:0 overruns:0 frame:0
TX packets:32 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1926 (1.8 KiB) TX bytes:2216 (2.1 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
8: eth0: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether 36:25:76:05:39:db brd ff:ff:ff:ff:ff:ff
ホストマシンの 10022 に来たパケットを Ubuntu の 22 に転送する。
EXPOSE 22で、公開するサービスを定義する
docker run -p 10022:22 -d atsushi/ubuntu_ssh_monit
docker run -p 22 -d atsushi/ubuntu_ssh_monit
docker run --net=bridge -p 10022:22 -d atsushi/ubuntu_ssh_monit
docker run --net=host -d atsushi/ubuntu_ssh_monit
docker run --net=none -i atsushi/ubuntu_ssh_monit