Distribute Cloud Environment on Ubuntu 14.04 with Docker

The Problem I Haven't Solved

Now, we can start using hadoop and hbase to record and analyze data by following this tutorial. Nevertheless, there are still problems I've met but not solved.

In section 4, after I docker run each containers, I have to modify every /etc/hosts of each containers to connect each others. But it will happen two problems.

First, it is inconvenient to modify every hosts file if large amounts of endpoint machines.

Second, if reboot containers, the IP of container will be automatically reset by Docker. Suppose you use HBase as your NoSQL DB, Zookeeper will store old IP and all regionservers can't trace back the master node.

I've surveyed some method to solve but not implement yet. Look at the following link:

http://jpetazzo.github.io/2013/10/16/configure-docker-bridge-network/

If I solve problems, I will update the book.

Update

2015/01/20

I've referenced the before link and try to solve the second problem I met. There are some new problems happened so that I don't solve it.

I've modify the interface IP and route of container successfully, but I can't ssh into container after do that. Th following code is what I use, maybe everybody can discuss on this issue in stackoverflow.

http://stackoverflow.com/questions/27937185/assign-static-ip-to-docker-container

pid=$(sudo docker inspect -f '{{.State.Pid}}' <container_name> 2>/dev/null)
sudo rm -rf /var/run/netns/*
sudo ln -s /proc/$pid/ns/net /var/run/netns/$pid
sudo ip link add A type veth peer name B
sudo brctl addif docker0 A
sudo ip link set A up
sudo ip link set B netns $pid
sudo ip netns exec $pid ip link set eth0 down
sudo ip netns exec $pid ip link delete eth0
sudo ip netns exec $pid ip link set dev B name eth0
sudo ip netns exec $pid ip link set eth0 address 12:34:56:78:9a:bc
sudo ip netns exec $pid ip link set eth0 down
sudo ip netns exec $pid ip link set eth0 up
sudo ip netns exec $pid ip addr add 172.17.0.1/16 dev eth0
sudo ip netns exec $pid ip route add default via 172.17.42.1