38次8.28(docker03:容器网络,主从镜像)

1.容器网络

1.本地⽹络

bridge

yum -y install bridge-utils

2.查看桥⽂件

yum provides *bin/brctl
brctl show
#使⽤docker network 查看桥
docker network ls

每⼀台dcoker host上的docker0所在⽹段完全⼀样,但是会造成跨主 机的容

器⽆法通信

3.host

与主机共享⽹络,可让容器连接外⽹ ,所有容器与docker主机在同⼀个⽹络

中,容器和外⽹相互访问

 docker network ls

创建⼀个新的容器

docker run -d -p80 -v /opt/:/usr/share/nginx/html/ centosnginx:v1 
​

4.查看ip,默认在桥上

docker inspect a4b6|grep IPA

5.绑定其他的桥

docker run -d --network harbor_harbor centosnginx:v1
​
docker inspect 21a2|grep IPAdd   # 使⽤--network对⽹桥的选择

6.绑定host主机⽹络

docker run -it --network host yum:v0 /bin/bash
yum -y install iprout   #内部查看ip是本地主机ip
​
 # 外部查看ip 没有
[root@docker001 001]# docker inspect 306d|grep IPAdd
2.主控node1

1.安装etcd数据库和flannel

yum -y install etcd
yum -y install flannel

2.修改etcd数据库配置文件

vim /etc/etcd/etcd.conf 
#第6行
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379,http://0.0.0.0:4001"
#第21行
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.1.10:2379,http://192.168.1.10:4001"

3.启动etcd服务

systemctl start etcd

4.查看端口是否启动

netstat -lnput|grep 2379       
netstat -lnput|grep 4001

5.设置开机启动

systemctl enable etcd

6.测试数据库存取功能

[root@node1 ~]# etcdctl set testdir/testkey0 1000
1000
[root@node1 ~]# etcdctl get testdir/testkey0 
1000

7.测试集群健康

etcdctl -C http://192.168.1.10:4001 cluster-health
member 8e9e05c52164694d is healthy: got healthy result from http://192.168.1.10:2379
cluster is healthy
​
etcdctl -C http://192.168.1.10:2379 cluster-health
member 8e9e05c52164694d is healthy: got healthy result from http://192.168.1.10:2379
cluster is heal
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值