Hi Friends,
I am new to Docker and have a Centos 7 on one of my desktops.
My plan is to see how Haproxy working as a load balancer, so I launched 2 pure Apache httpd containers and 1 pure Haproxy container on top of Centos7.
Fist step I started all 3, looks fine .
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d09f3b545d71 haproxy “/docker-entrypoint.s” 22 seconds ago Up 18 seconds admiring_easley
2e9d22276efa httpd “/bin/bash” 51 seconds ago Up 48 seconds 80/tcp peaceful_shockley
a260f3da54c7 httpd “/bin/bash” 49 minutes ago Up 49 minutes 80/tcp hopeful_sinoussi
Here is the network status
docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 0.0.0.0
inet6 fe80::42:7aff:fea6:aef1 prefixlen 64 scopeid 0x20
ether 02:42:7a:a6:ae:f1 txqueuelen 0 (Ethernet)
RX packets 172 bytes 10940 (10.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 59 bytes 5008 (4.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.113 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::c5db:ac3c:d791:18e8 prefixlen 64 scopeid 0x20
ether 00:1d:60:49:cd:37 txqueuelen 1000 (Ethernet)
RX packets 20240 bytes 11260373 (10.7 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 11713 bytes 1371142 (1.3 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1 (Local Loopback)
RX packets 3802 bytes 335650 (327.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3802 bytes 335650 (327.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
veth49f493e: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::a8:7dff:fe60:14fa prefixlen 64 scopeid 0x20
ether 02:a8:7d:60:14:fa txqueuelen 0 (Ethernet)
RX packets 26 bytes 2144 (2.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 44 bytes 3628 (3.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
vetha7d0849: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::bcd8:2ff:fe24:f9df prefixlen 64 scopeid 0x20
ether be:d8:02:24:f9:df txqueuelen 0 (Ethernet)
RX packets 8 bytes 648 (648.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 16 bytes 1296 (1.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
vethd788e5f: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::a0fc:24ff:fe78:b6c5 prefixlen 64 scopeid 0x20
ether a2:fc:24:78:b6:c5 txqueuelen 0 (Ethernet)
RX packets 8 bytes 648 (648.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 8 bytes 648 (648.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:b3:9a:90 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
I am going to see whether the httpd contain could be accessed, so shut down them all. and tried to map the port 80 of host to httpd container port 80 via
$sudo docker run -P httpd /bin/bash
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8ee495e91753 httpd “/bin/bash” 21 seconds ago Exited (0) 17 seconds ago adoring_brown
============================
$ sudo docker run -i -p 127.0.0.1:80:80 httpd /bin/bsah
container_linux.go:247: starting container process caused “exec: “/bin/bsah”: stat /bin/bsah: no such file or directory”
/usr/bin/docker-current: Error response from daemon: invalid header field value “oci runtime error: container_linux.go:247: starting container process caused “exec: \”/bin/bsah\”: stat /bin/bsah: no such file or directory"\n".
$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8755b1ebdd28 httpd “/bin/bsah” 54 seconds ago Created fervent_goldstine
I have got faint. Could I have your guide?
My original thought was
I should be able to access the httpd container via Http://192.168.0.113:80 ( the host ip address with port80 if I map the Centos port 80 to httpd container port 80, just like the port forward in my home router.
Host(Centos 7) Httpd container
------------------>192.168.0.113:80|172.17.0.1------------------->172.17.0.2:80
Thanks very much!
corydon