<commit_before>Miscellaneous

To setup Mesos with Docker
1. Update hosts
sudo vi /etc/hosts

2. Add the following line
127.0.0.1  localhost.localdomain

3. Start the private registry
docker run \
    -d --name registry \
    -e SETTINGS_FLAVOR=local \
    -e STORAGE_PATH=/registry \
    -v /tmp/registry:/registry \
    -p 80:5000\
    registry

Add an image from the public registry to the private registry
1. 
# First, make sure you have the "ubuntu" repository:
docker pull ubuntu

# Then, find the image id that corresponds to the ubuntu repository
docker images | grep ubuntu | grep latest
ubuntu  latest  53bf7a53e890  12 weeks ago  263 MB (virtual 263 MB)

# Tag to create a repository with the full registry location.
# The location becomes a permanent part of the repository name.
docker tag 53bf7a53e890 localhost.localdomain/ubuntu

# Finally, push the new repository to its home location.
docker push localhost.localdomain/ubuntu

# create a docker app by posting to Marathon using curl
curl -X POST -H "Content-Type: application/json" http://localhost:8080/v2/apps -d@docker.json

Setup haproxy
See https://mesosphere.github.io/marathon/docs/service-discovery-load-balancing.html
1. Install haproxy
sudo apt-get install haproxy

Get script to setup haproxy.cfg
https://raw.githubusercontent.com/mesosphere/marathon/master/bin/haproxy-marathon-bridge

./haproxy-marathon-bridge 192.168.33.10:8080 > haproxy.cfg

haproxy -f haproxy.cfg -p haproxy.pid -sf $(cat haproxy.pid)

Deploy Docker containers with Marathon
http://frankhinek.com/deploy-docker-containers-on-mesos-0-20/

To install docker on ubuntu
sudo apt-get update
sudo apt-get install docker.io
sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker
sudo sed -i '$acomplete -F _docker docker' /etc/bash_completion.d/docker.io

To get the IPython notebook images
1. Get the image
sudo docker pull ipython/notebook

2. Run the notebook
sudo docker run -d -p 8888:8888 -e "PASSWORD=<PASSWORD>" ipython/notebook


Add port forwarding for running VM
set /p VBOX_ID=<.vagrant\machines\default\virtualbox\id
VBoxManage controlvm %VBOX_ID% natpf1 "tcp5000,tcp,,5000,,5000

http --session abc http://tl-fqa-01:8100/engine/noop?user=12312 Admin-Name:U501 Admin-Password:<PASSWORD>

http --session=session.json http://tl-fqa-01:8100/engine/noop?user=12312

session.json
{
    "__meta__": {
        "about": "HTTPie session file",
        "help": "https://github.com/jkbr/httpie#sessions",
        "httpie": "0.8.0"
    },
    "auth": {
        "password": <PASSWORD>,
        "type": null,
        "username": null
    },
    "cookies": {},
    "headers": {
        "Admin-Name": "U501",
        "Admin-Password": "<PASSWORD>"
    }
}

 sudo docker run -t -i -v /vagrant/java:/java -m 800m tomcat:6.0.43-jre7 java -cp //java MemLeak<commit_msg>updated doc to include tunnel between master & slave<commit_after>Miscellaneous

To setup Mesos with Docker
1. Update hosts
sudo vi /etc/hosts

2. Add the following line
127.0.0.1  localhost.localdomain

3. Start the private registry
docker run \
    -d --name registry \
    -e SETTINGS_FLAVOR=local \
    -e STORAGE_PATH=/registry \
    -v /tmp/registry:/registry \
    -p 80:5000\
    registry

Add an image from the public registry to the private registry
1. 
# First, make sure you have the "ubuntu" repository:
docker pull ubuntu

# Then, find the image id that corresponds to the ubuntu repository
docker images | grep ubuntu | grep latest
ubuntu  latest  53bf7a53e890  12 weeks ago  263 MB (virtual 263 MB)

# Tag to create a repository with the full registry location.
# The location becomes a permanent part of the repository name.
docker tag 53bf7a53e890 localhost.localdomain/ubuntu

# Finally, push the new repository to its home location.
docker push localhost.localdomain/ubuntu

# create a docker app by posting to Marathon using curl
curl -X POST -H "Content-Type: application/json" http://localhost:8080/v2/apps -d@docker.json

Setup haproxy
See https://mesosphere.github.io/marathon/docs/service-discovery-load-balancing.html
1. Install haproxy
sudo apt-get install haproxy

Get script to setup haproxy.cfg
https://raw.githubusercontent.com/mesosphere/marathon/master/bin/haproxy-marathon-bridge

./haproxy-marathon-bridge 192.168.33.10:8080 > haproxy.cfg

haproxy -f haproxy.cfg -p haproxy.pid -sf $(cat haproxy.pid)

Deploy Docker containers with Marathon
http://frankhinek.com/deploy-docker-containers-on-mesos-0-20/

To install docker on ubuntu
sudo apt-get update
sudo apt-get install docker.io
sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker
sudo sed -i '$acomplete -F _docker docker' /etc/bash_completion.d/docker.io

To get the IPython notebook images
1. Get the image
sudo docker pull ipython/notebook

2. Run the notebook
sudo docker run -d -p 8888:8888 -e "PASSWORD=<PASSWORD>" ipython/notebook


Add port forwarding for running VM
set /p VBOX_ID=<.vagrant\machines\default\virtualbox\id
VBoxManage controlvm %VBOX_ID% natpf1 "tcp5000,tcp,,5000,,5000

http --session abc http://tl-fqa-01:8100/engine/noop?user=12312 Admin-Name:U501 Admin-Password:<PASSWORD>

http --session=session.json http://tl-fqa-01:8100/engine/noop?user=12312

session.json
{
    "__meta__": {
        "about": "HTTPie session file",
        "help": "https://github.com/jkbr/httpie#sessions",
        "httpie": "0.8.0"
    },
    "auth": {
        "password": <PASSWORD>,
        "type": null,
        "username": null
    },
    "cookies": {},
    "headers": {
        "Admin-Name": "U501",
        "Admin-Password": "<PASSWORD>"
    }
}

 sudo docker run -t -i -v /vagrant/java:/java -m 800m tomcat:6.0.43-jre7 java -cp //java MemLeak

To create a tunnel between slave and master
MASTER_IP=10.0.0.100
SLAVE_IP=10.0.0.200
HOST_MASTER_IP=192.168.0.127

Port 2200 on master host is mapped to master guest port 22

/etc/ssh/sshd_config should contain the following
 PermitRootLogin without-password
 PermitTunnel yes

sudo ssh -NTCf -w 0:0 -i private_key -p 2200 $HOST_MASTER_IP

After connecting using ssh you should be able to see the tun0 interface on master and slave
ip addr show tun0

On master machine
ip link set tun0 up
ip addr add $MASTER_IP/32 peer $SLAVE_IP dev tun0

On slave machine
ip link set tun0 up
ip addr add $SLAVE_IP/32 peer $MASTER_IP dev tun0

Now ping to the other machine will work
From master machine
ping $SLAVE_IP

From slave machine
ping $MASTER_IP

{'fraction_non_alphanumeric': 0.10159674389480275, 'fraction_numerical': 0.046336881653099564, 'mean_word_length': 3.5603140613847253, 'pattern_counts': {'":': 24, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 9, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1397505', 'n_tokens_mistral': 2444, 'n_tokens_neox': 2108, 'n_words': 697}