systemctl start docker docker pull nginx:1.17-alpine
docker run --name web1 -d nginx:1.17-alpine docker exec -it web1 /bin/sh echo '<h1>web1<h1>' > /usr/share/nginx/html/index.html docker run --name web2 -d nginx:1.17-alpine docker exec -it web2 /bin/sh echo '<h1>web2<h1>' > /usr/share/nginx/html/index.html
查看Server端和容器的ip地址
Server端:直接運行ifconfig
容器:用docker exec
進入容器的狀況下運行ifconfig
nginx
yum -y install ipvsadm
ipvsadm -A -t Server端ip地址:80 -s rr ipvsadm -a -t Server端ip地址:80 -r 容器ip地址:80 -m
curl Server端ip地址
iptables -I INPUT -p tcp --dport 80 -j ACCEPT