Docker setup

Some parts of this guide are out-of-date and need fixing

How to setup docker

How to setup docker on different systems so that it starts automatically on startup, and authenticate.

Ubuntu 14.04

sudo apt update && sudo apt install wget  # Install wget just in case you don't have it
wget -qO- https://get.docker.com/ | sh    # Install docker - NB: doesn't actually start the docker service
sudo usermod -aG docker `whoami`          # Add yourself to the docker group
# Now log out and back in again
sudo service docker start                 # Make sure the docker service is running

NB: If you’re using 16.04 pre-release, you’ll probably need to manually set your docker.sources file to use wily, as xenial doesn’t seem to exist yet.

NB: You’ll probably also need to fix docker’s DNS using this guide

MacOS

This is out-of-date. You should now use use Docker Toolbox

# Install dependencies
brew tap caskroom/cask
brew cask install virtualbox
brew install boot2docker

# Setup boot2docker to run on on startup
ln -sfv /usr/local/opt/boot2docker/*.plist ~/Library/LaunchAgents  # run at startup
echo '$(boot2docker shellinit)' >> ~/.bash_profile

# Initialize boot2docker
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.boot2docker.plist  # Run now
boot2docker init                                                       # Initialize VM
boot2docker up                                                         # Start boot2docker
echo -e "\n`boot2docker shellinit`"                                    # Set environment variables

# Test docker works
docker run hello-world

When you restart your computer, docker should now work seamlessly.

For some people the above method doesn’t seem to work properly. In this case, create a new image with TLS disabled as follows:

boot2docker stop    # Stop any running VM
boot2docker delete  # Delete existing VM
boot2docker init    # Make a clean VM
boot2docker up      # Start the VM
boot2docker ssh     # Log into the VM
$ sudo echo 'DOCKER_TLS = "no"' >> /var/lib/boot2docker/profile  # Turn off TLS
$ exit
boot2docker restart # Restart everything

Authentication

First you’ll need an account on Docker hub with access to private repositories on /u/ubuntudesign - ask another member of the team to add you if you don’t have access.

# Login to hub.docker.com with an account that has access
docker login

# Check you can now pull the python-auth image
docker pull ubuntudesign/python-auth
# If you can't see ubuntudesign/python-auth then ask someone to add you

Setting up Docker on Canonicals DNS

First you will need to edit your Docker configuration file (/lib/systemd/system/docker.service)

sudo vim /lib/systemd/system/docker.service

Edit the line starting ExecStart with the following:

ExecStart=/usr/bin/docker daemon --dns 8.8.8.8 --dns 10.20.64.1 -H fd://

Save and Quit

Then follow that with two commands:

sudo systemctl daemon-reload
sudo service docker restart