-
-
Save sirvon/0f0597b3b8195b71673c to your computer and use it in GitHub Desktop.
This file contains 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/sh | |
# This Script aims to setup a docker environment for Linux or OSX with docker client, docker-machine and docker-compose | |
# All binaries are install in /usr/local/bin/ directory. | |
RED='\033[0;31m' | |
GREEN='\033[0;32m' | |
NC='\033[0m' # No Color | |
os=$(uname -s) | |
arch=$(uname -m) | |
# Install Docker client | |
docker_bin_url="https://get.docker.com/builds/$os/$arch/docker-latest" | |
echo "${GREEN}>> Download docker client binary${NC}" | |
echo $docker_bin_url | |
curl --progress-bar -o /usr/local/bin/docker $docker_bin_url | |
chmod +x /usr/local/bin/docker | |
# Install Docker machine | |
docker_machine_bin_url="https://github.com/docker/machine/releases/download/v0.3.0/docker-machine_$(echo $os| tr '[:upper:]' '[:lower:]')-amd64" | |
echo "\n${GREEN}>> Download Docker machine${NC}" | |
echo $docker_machine_bin_url | |
curl --progress-bar -L $docker_machine_bin_url > /usr/local/bin/docker-machine | |
chmod +x /usr/local/bin/docker-machine | |
# Install Docker Compose | |
docker_compose_bin_url="https://github.com/docker/compose/releases/download/1.3.1/docker-compose-$os-$arch" | |
echo "\n${GREEN}>> Download Docker compose${NC}" | |
curl --progress-bar -L $docker_compose_bin_url > /usr/local/bin/docker-compose | |
chmod +x /usr/local/bin/docker-compose | |
# Test docker-compose because sometimes the binary raise the following error 'Illegal instruction: 4' | |
docker-compose 2>/dev/null | |
if [ $? -gt 0 ]; then | |
sudo pip install -U docker-compose==1.3.1 | |
fi | |
# Create a Docker machine on virtualbox | |
echo "\n${GREEN}>> Create a dev machine on virtualbox${NC}" | |
docker-machine create --driver virtualbox dev | |
if [ $? -eq 0 ];then | |
eval "$(docker-machine env dev)" | |
echo $(docker-machine env dev) >> ~/.bash_profile | |
fi | |
echo "\n\n${GREEN}Done! You should see infos about docker below :${NC}" | |
docker info | |
This file contains 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
sudo /sbin/route -n add -net 172.17.0.0 -netmask 255.255.0.0 -gateway `docker-machine dev ip` |
This file contains 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 | |
# On OSX | |
OSX_IP=$(ifconfig | pcregrep -M -o '^[^\t:]+:([^\n]|\n\t)*status: active'|grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*'|grep -Eo '([0-9]*\.){3}[0-9]*') | |
sudo sh -c "echo \"/Users ${OSX_IP} -alldirs -mapall=501:20\" >> /etc/exports" | |
sudo sh -c 'echo "nfs.server.mount.require_resv_port = 0" >> /etc/nfs.conf' | |
sudo nfsd restart | |
# On docker machine | |
docker-machine ssh dev "sudo sh -c 'cat <<EOF > /var/lib/boot2docker/bootlocal.sh | |
sudo umount /Users | |
sudo /usr/local/etc/init.d/nfs-client start | |
sudo mount -t nfs -o noacl,async,noatime,soft,nolock,vers=3,udp,proto=udp,rsize=8192,wsize=8192,namlen=255,timeo=10,retrans=3,nfsvers=3,actimeo=2 $OSX_IP:/Users /Users | |
EOF' && sudo sh -c 'chmod 755 /var/lib/boot2docker/bootlocal.sh'" | |
docker-machine restart dev |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment