docker-engin 1.13
linux 内核 4.8.11-1.el7.elrepo.x86_64
1.升级内核
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
yum --enablerepo=elrepo-kernel install kernel-ml-devel kernel-ml -y
awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg
grub2-set-default 0
reboot
#tee /etc/yum.repos.d/docker.repo <<-'EOF'
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF
2.创建实例
所有节点创建两种桥接模式:
docker network create -d macvlan --subnet=10.237.86.0/24 --gateway=10.237.86.254 -o parent=eth1 -o macvlan_mode=bridge macvlan1
docker network create -d bridge --subnet=192.168.248.0/24 --gateway=192.168.248.1 -o com.docker.network.bridge.name=dockerbr0 br11
===直播绑定物理机网桥上,物理机IP不能是桥接模式,不能有eth:1绑定到py1上
docker network create -d bridge --subnet=10.237.86.0/24 --gateway=10.237.86.254 -o com.docker.network.bridge.name=eth1 brid
===
docker run --net=macvlan1 --ip=10.237.86.39 -it -d --name=kldocker centos /bin/bash
docker run -it -d --net=br11 --ip=192.168.248.2 --name=brtest centos /bin/bash
给内网192.168.248.*容器添加10.237网络ip
docker network connect --ip 10.237.0.* br11 container
创建容器实例:
#/bin/bash
NAME=dump01
NET=br11
IP=192.168.248.2
mkdir -p /ssd/dockeruserfile/${NAME}/export
docker run -it -d --privileged --net=${NET} --ip=${IP} --name=${NAME} -h ${NAME} \
-p 51022:22 \
-v /ssd/dockeruserfile/${NAME}/export:/export \
-v /etc/localtime:/etc/localtime:ro \
ledo_v1 /root/dockerdaemon.sh
其他:
export DOCKER_MACHINE_NAME="docker-ct7-7-ds"
docker run -itd --name=ledo_test02 --network=macvlan1 -e constraint:node==docker-ct7-7-ds --ip=10.237.86.28 centos /bin/bash
====
docker -H tcp://10.237.86.30:2375 run -itd --name=ledo_test01 --network=macvlan1 --ip=10.237.86.27 centos /bin/bash
docker -H tcp://10.237.86.30:2375 run -it -d --net=br11 --ip=192.168.248.2 --name=ledo_test02 centos /bin/bash
====
docker service create --replicas 3 --name helloworld03 --network=ingress alpine ping docker.com
docker network connect --ip container
==============================================物理机ping 通过macvlan bridge模式容器ip
10.11.0.45 物理机eth1内网IP
docker network create -d bridge --subnet=10.11.0.0/21 --gateway=10.11.0.45 -o com.docker.network.bridge.name=eth1 br11
docker run -it -d --net=br11 --privileged --ip=10.11.2.115 --name=brtest ledo_v1 /bin/bash
容器中
route del default
route add default gw 10.11.3.254
=============================================