So, there's always
the oops moment when you know that you did something wrong, often before you
did it.
I closed one of the
putty windows. Wasn't sure how to get
back to my new container.
Update: https://github.com/docker/docker/issues/2838 Control-P and Control-Q on the console allow you to move into and out of the psuedo-shell
Update: https://github.com/docker/docker/issues/2838 Control-P and Control-Q on the console allow you to move into and out of the psuedo-shell
As it turns out, the
container is given a name (assumption that a name could be applied to it also).
docker ps - to see
the running containers
nelson@lab1:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4a567ec8d878 alpine "/bin/sh" 4 hours ago Up 4 hours serene_jennings
60f137369165 alpine "/bin/sh" 18 hours ago Up 18 hours nauseous_meninsky
I'm after
nauseous_meninsky (have to look up where they get these names later).
nelson@lab1:~$ docker attach nauseous_meninsky
/ #
Whew! Disaster averted. Back in my container!
……
Getting back to the
networking, the default docker network is an RFC1918 class B. It seemed like a waste of address space to
me, so let's create another network in docker.
docker network
create -d bridge --subnet 172.16.1.0/24 docker1
-d is the driver, we
want a bridge
--subnet defines the
network range, looks like the default gateway is always the first in the range
docker1 is the
defined name, like docker0 in the ifconfig -a from the host
nelson@lab1:~$ docker network create -d bridge --subnet 172.16.1.0/24
docker1
11f4ac20d39dd523c48fe3ac6462dd8bcb4a7247dba5162bec37d46208315bc2
docker network ls -
to see if it added to the networks
nelson@lab1:~$ docker network ls
NETWORK ID NAME DRIVER
1c9307d1163e bridge bridge
11f4ac20d39d
docker1 bridge
72a37254aedb host host
ae03349bbf0e none null
Let's create a
container and associate it to the new network.
docker run
--net=docker1 alpine -it alpine /bin/sh
nelson@lab1:~$ docker run --net=docker1 -it alpine /bin/sh
/ # ifconfig -a
eth0 Link encap:Ethernet HWaddr 02:42:AC:10:01:02
inet addr:172.16.1.2
Bcast:0.0.0.0 Mask:255.255.255.0
inet6 addr:
fe80::42:acff:fe10:102%32720/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500
Metric:1
RX packets:54 errors:0 dropped:0
overruns:0 frame:0
TX packets:8 errors:0 dropped:0
overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:11822 (11.5 KiB) TX bytes:648 (648.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1%32720/128 Scope:Host
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)
/ #
nelson@lab1:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2b9cacaef4f6 alpine "/bin/sh" 36 seconds ago Up 35 seconds sick_mclean
4a567ec8d878 alpine "/bin/sh" 4 hours ago Up 4 hours serene_jennings
60f137369165 alpine "/bin/sh" 19 hours ago Up 19 hours nauseous_meninsky
Now, lets see what
it can talk to from the new shell.
Internet - Success
/ # ping 8.8.8.8
PING 8.8.8.8
(8.8.8.8): 56 data bytes
64 bytes from
8.8.8.8: seq=0 ttl=57 time=24.809 ms
64 bytes from
8.8.8.8: seq=1 ttl=57 time=25.089 ms
64 bytes from
8.8.8.8: seq=2 ttl=57 time=29.708 ms
^C
--- 8.8.8.8 ping
statistics ---
3 packets
transmitted, 3 packets received, 0% packet loss
round-trip
min/avg/max = 24.809/26.535/29.708 ms
Gateway - Success
/ # ping 172.16.1.1
PING 172.16.1.1
(172.16.1.1): 56 data bytes
64 bytes from
172.16.1.1: seq=0 ttl=64 time=0.130 ms
64 bytes from
172.16.1.1: seq=1 ttl=64 time=0.117 ms
64 bytes from
172.16.1.1: seq=2 ttl=64 time=0.111 ms
^C
--- 172.16.1.1 ping
statistics ---
3 packets
transmitted, 3 packets received, 0% packet loss
round-trip
min/avg/max = 0.111/0.119/0.130 ms
Container 1 -
Failure
/ # ping 172.17.0.2
PING 172.17.0.2
(172.17.0.2): 56 data bytes
^C
--- 172.17.0.2 ping
statistics ---
9 packets
transmitted, 0 packets received, 100% packet loss
Container 2 -
Failure
/ # ping 172.17.0.3
PING 172.17.0.3
(172.17.0.3): 56 data bytes
^C
--- 172.17.0.3 ping
statistics ---
4 packets
transmitted, 0 packets received, 100% packet loss
So, there's no path
between 172.16.1.0/24 and 172.17.0.0/16
The routes from the
host
nelson@lab1:~$ ip route
default via
192.168.123.254 dev wlan0 proto static
172.16.1.0/24 dev
br-11f4ac20d39d proto kernel scope link
src 172.16.1.1
172.17.0.0/16 dev
docker0 proto kernel scope link
src 172.17.0.1
192.168.123.0/24 dev
wlan0 proto kernel scope link
src 192.168.123.24 metric 9
Modified for 2 bridges attached to docker |
So, maybe it looks a
little more like this.
No comments:
Post a Comment