Summary:
I have CentOS container named "centos1" that have HTTP server.I want to forward incoming request to port 8081 on the docker physcial host to port 80 on the 'centos' container.
Install 'httpd' on 'centos1' container:
[root@docker1 ~]# hostname docker1.ab.lab
[root@docker1 ~]# docker ps -s CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES SIZE 766f948a89d6 centos "/bin/bash" 2 hours ago Up 41 minutes centos1 217 MB (virtual 416 MB)
[root@docker1 ~]# docker attach centos1
[root@766f948a89d6 /]# ip a 1: lo:mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 26: eth0@if27: mtu 1500 qdisc noqueue state UP group default link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff link-netnsid 0 inet 172.17.0.2/16 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::42:acff:fe11:2/64 scope link valid_lft forever preferred_lft forever
[root@766f948a89d6 /]# yum install httpd -y [root@766f948a89d6 /]# systemctl enable httpd [root@766f948a89d6 /]# httpd & [1] 59
[root@766f948a89d6 /]# ps -ef | grep httpd root 60 1 0 12:18 ? 00:00:00 httpd apache 61 60 0 12:18 ? 00:00:00 httpd apache 62 60 0 12:18 ? 00:00:00 httpd apache 63 60 0 12:18 ? 00:00:00 httpd apache 64 60 0 12:18 ? 00:00:00 httpd apache 65 60 0 12:18 ? 00:00:00 httpd root 67 1 0 12:18 ? 00:00:00 grep --color=auto httpd
[root@766f948a89d6 /]# netstat -tupenl Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name tcp6 0 0 :::80 :::* LISTEN 0 117163 60/httpd
[root@766f948a89d6 /]# echo "httpd enabled on centos1 container" >> /var/www/html/index.html
[root@766f948a89d6 /]# lynx --dump 172.17.0.2 httpd enabled on centos1 container
No comments:
Post a Comment