Pipework-Weave-Flannel-Calico

docker run -d --name nginx nginx
docker inspect --format '{{.NetworkSettings.IPAddress}}' nginx

docker run -d --name foobar -h foobar busybox sleep 300
docker exec -it nginx cat /etc/hosts

touch Dockerfile
vim Dockerfile

FROM python:2.7.10
RUN pip install flask
COPY hello.py /tmp/hello.py

CMD [ "python" , "/tmp/hello.py" ]

docker build -t flask
docker run -d --name foobar flask
docker inspect -f '{{.NetworkSettings.IPAddress}}' foobar

docker kill foobar

docker rm foobar

docker run -d -p 5000 --name foobar flask

docker ps -a

docker port foobar 5000

docker run -d -p flask

docker run -d -p 5000/tcp -p 53/tcp flask

iptables -L

ps -ef | grep docker

docker run -d --name database -e MYSQL_ROOT_PASSWORD=root mysql
docker run -d --link database:db --name web runseb/hostname
docker run -d --link web:application --name lb nginx
docker ps

docker exec -ti web env| grep DB

docker exec -ti lb env | grep APPLICATION

docker exec -ti web cat /etc/hosts

docker exec -ti lb cat /etc/hosts

###
--link
###

docker inspect -f "{{.HostConfig.Links}}" application
docker ipspect 0f "{{.HostConfig.Links}}" lb


docker run -ti --rm ubuntu:14.04 bash

###
btctl
###

echo 1 /proc/sys/net/ipv4/ip_forward

iptables -t nat -L


docker run -it --rm --net=none ubuntu:14.04 bash

docker run -it --rm --net=host utuntu:14.04 bash

docker run -it --rm - cookbook ubuntu:14.04 bash

docker ps
#same network
docker run -ti --net=container:dockerpsname ubuntu"14.04 bash

systemctl stop docker
echo DOCKER_OPTS=\"--iptables=false --ip-forward=false\" >> /etc/default/docker
systemctl start docker

iptables -t net -D POSTROUTING 1

echo 0 /proc/sys/net/ipv4/ip_forward

systemctl restart docker

docker run -ti --rm ubuntu:14.01 bash

echo 1 /prco/sys/net/ipv4/ip_forward

iptables -t net -A POSTROUTING -s 172.17.0.0/16 -j MASQUERADE

iptables -A DOCKER -p -icmp --icmp-type echo-request -j ACCEPT
iptables -A DOCKER -p -icmp --icmp-type echo-replay -j ACCEPT


################################
pipework
#docker network
https://github.com/jpetazzo/pipework

docker run -it --rm --net none --name cookbook ubnunt:14.01 bash

ip -d link show eth1
route

ip -d link show

brctl show

iptables -t net -A POSTROUTING-s 192.168.0.0/16/ -j MASQUERADE


##############



pepework br0 cookbook 192.168.10/24@192.168.1.254

ip link set br0 down

brctl delbr br0



########################

brctl addbr br0
ip addr add 192.168.1.254/24 dev br0
ip link set dev br0 up

ip linke add foo type veth peer name bar
brctl addif br0 foo
ip link set foo up

ip -d link

ip -d link show
brctl show

cd /var/run

ln -s /var/run/docker/netns netns
ip netns
NID=$(sudo ip netns)

ip link set netns
ip netns exec


ip link set var netns $NID
ip netns exec $NID ip link set dev bar name eth1
ip netns exec $NID ip link set eth1 address 00:00:00:00:00:00
ip betbs exec $NID ip link set eth1 up

ip netns exec $NID ip addr add 192.168.1.1/24 dev eth1
ip netns exec $NID ip route add default via 192.168.1.254

iptables -t net -A POSTROUTING -s 192.168.0.0/24 -j MASQUERADE


systemctl stop docker
ip link set docker0 down
brctl delbr docker0
brctl addbr cookbook
ip link set cookbook up
ip addr add 10.0.0.1/24/ dev cookbook
echo 'DOCKER_OPTS="-bcoookbook"' >> /etc/default/docker
systemctl restart docker

ip addr show eht0

iptables -t nat -L

ip link set dookbook down
brctl delbr cookbook


###############



docker netowrk ls
docker service ls docker run -it -rm ubuntu:14.04 bash

➜ docker service ls
Error response from daemon: This node is not a swarm manager. Use "docker swarm init" or "docker swarm join" to connect this node to swarm and try again.

docker network create -d overlay foobar

docker run -it --rm --publish-service=bar.foobar.overlay ubuntu:14.04 bash

docker service ls

docker inspect -f '{{.NetworkSettings.SanboxKey}}' dockername

#########
ip netns exec dockername ip addr show eth0