Last active
May 24, 2016 12:51
-
-
Save guilhermef/dad86614ed5b9c52a828ae5fb0956b9a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
registryhost="tsuru-registry-01.eduk.vpc" | |
registryport="5000" | |
dockerhost="127.0.0.1" | |
dockerport="2375" | |
version=$(docker version 2>/dev/null | grep " Version" | cut -c16-) | |
if [[ $version != "" ]]; then | |
echo "Skipping docker installation, version installed: $version" | |
else | |
echo "Installing docker..." | |
curl -sSL https://get.docker.com/ | sudo sh | |
sudo apt-get install docker-engine=1.10.3-0~trusty -y --force-yes | |
opts=$(bash -c 'source /etc/default/docker && echo $DOCKER_OPTS') | |
if [[ ! $opts =~ :// ]]; then | |
echo "Changing /etc/default/docker to listen on tcp://0.0.0.0:${dockerport}..." | |
echo "DOCKER_OPTS=\"\$DOCKER_OPTS -H tcp://0.0.0.0:${dockerport} -H unix:///var/run/docker.sock --insecure-registry=${registryhost}:${registryport}\"" | sudo tee -a /etc/default/docker > /dev/null | |
fi | |
sudo service docker stop 1>&2 2>/dev/null || true | |
sudo service docker start | |
sleep 5 | |
home_host=$(bash -ic 'source ~/.bashrc && echo $DOCKER_HOST') | |
if [[ $home_host != "tcp://$dockerhost:$dockerport" ]]; then | |
echo "Adding DOCKER_HOST to ~/.bashrc" | |
echo -e "export DOCKER_HOST=tcp://$dockerhost:$dockerport" | tee -a ~/.bashrc > /dev/null | |
fi | |
export DOCKER_HOST=tcp://$dockerhost:$dockerport | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment