docker install and setup for mac and debian
I have a couple of scripts to help get your servers and laptops setup to use docker. install_dockermac is for MacOSX installation, tested on Mavericks and Yosemite.
The second script (farther down the page), is for Debian based systems. I have tested it with LMDE, Debian Wheezy, and Debian Testing. Should work on any debian based system.
I use these to ensure that my environment is identical across my Mac and my Debian machines. No issues reported so far, but please let me know if you see any ways to improve them in the comments below.
install_dockermac
# Quick Install for Docker on Mac OSX
# Author: Benjamin H. Graham <bman@bman.io>
# Must be run as root
# Usage: curl -s bman.io/i/install_dockermac|sudo bash
cd ~
echo "Downloading docker binary";
curl -Ls "https://github.com/boot2docker/osx-installer/releases/download/v1.2.0/Boot2Docker-1.2.0.pkg" -o "Boot2Docker-1.2.0.pkg";
echo "Installing docker service";
installer -pkg Boot2Docker-1.2.0.pkg -target /;
echo "Cleaning up downloaded files";
#rm Boot2Docker-1.2.0.pkg;
echo "Initializing docker";
boot2docker init;
echo "Configuring Docker VM to run at startup";
mkdir -p /System/Library/StartupItems/docker;
echo "boot2docker start" > /System/Library/StartupItems/docker-start;
chmod +x /System/Library/StartupItems/docker/docker-start;
echo "export DOCKER_HOST=tcp://$(boot2docker ip 2>/dev/null):2375" >> /etc/profile;
# start it up now and test it out
echo "Starting docker...";
boot2docker start;
echo "Testing docker with hello-world";
export DOCKER_HOST=tcp://$(boot2docker ip 2>/dev/null):2375;
docker run hello-world;
echo "You should see a hello world message above.";
echo "You will need to logout and back in to use docker. Otherwise run this: ";
echo "DOCKER_HOST=tcp://$(boot2docker ip 2>/dev/null):2375";
Example usage:
curl -s bman.io/i/install_dockermac | bash
or
curl -s https://gist.githubusercontent.com/bhgraham/9dced0918dc20edd1484/raw/744e2f3ec355dc9a9310527c77234dbb2a192cde/install_dockermac | sudo bash
install_dockerdeb
# Quick Install for Docker on Debian (LMDE, Mint, Ubuntu, etc)
# Author: Benjamin H. Graham <bman@bman.io>
# Usage: curl -s bman.io/i/install_dockerdeb | bash
# Add debian repo
echo "Adding the debian repository for docker"
echo deb http://get.docker.io/ubuntu docker main | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
echo "Updating apt repos"
sudo apt-get update -qq
echo "Installing docker"
sudo apt-get install -y lxc-docker
echo "Enabling current user to use docker"
sudo groupadd docker
# Add the connected user "${USER}" to the docker group.
# Change the user name to match your preferred user.
# You may have to logout and log back in again for
# this to take effect.
sudo gpasswd -a ${USER} docker
echo 'DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4 -H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock"'| sudo tee /etc/default/docker
echo "export DOCKER_HOST=tcp://127.0.0.1:2375" | sudo tee /etc/profile;
# Restart the Docker daemon.
echo "Restarting docker daemon"
sudo service docker restart
echo "Testing docker with hello-world";
export DOCKER_HOST=tcp://127.0.0.1:2375;
docker -H tcp://127.0.0.1:2375 run hello-world;
echo "You should see a hello world message above.";
echo "You will need to logout and back in to use docker. Otherwise run this: ";
echo "DOCKER_HOST=tcp://127.0.0.1:2375";
echo "Or you can test again with this: ";
echo "docker -H tcp://127.0.0.1:2375 run hello-world";
Example usage:
curl -s bman.io/i/install_dockerdeb | bash
or
curl -s https://gist.githubusercontent.com/bhgraham/ed9f8242dc610b1f38e5/raw/58c162147be40c53a8a35b525e62dea86f49ebec/install_dockerdeb | sudo bash