Getting Started with Docker and Docker Compose on Ubuntu 14.04

Step 1 - Download and Install Docker

I started with this guide from Digital Ocean. I already had a configured instance of Ubuntu 14.04, and began by downloading docker and running the install script:

wget -qO- https://get.docker.com/ | sh

Next add your user to the 'docker' group, in my case I was logged in under the default 'ubuntu' user account:

sudo usermod -aG docker ubuntu

Step 2 - Download and Install Docker Compose

Download 'python-pip':

sudo apt-get -y install python-pip

Install 'docker-compose' via 'pip':

sudo pip install docker-compose

Step 3 - Setup and Initialize a Container with Docker Compose

Create a docker directory, enter into it, and create a filed called docker-compose.yml which will be the configuration file for our test container:

ubuntu ~ $ mkdir docker
ubuntu ~ $ cd docker/
ubuntu ~/docker $ vim docker-compose.yml
ubuntu ~/docker $ cat docker-compose.yml
my-test:
  image: hello-world
ubuntu ~/docker $ docker-compose up -d
ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

If you run into the 'Couldn't connect to Docker daemon' error as seen above, ensure you have added your current user to the 'docker' group (see Step 2), and make sure to log out of your terminal prompt and log back in in order for 'usermod' change to take effect. Then retry the command (the -d flag allows the 'docker-compose' command to run in the background):

ubuntu ~/docker $ docker-compose up -d
Creating docker_my-test_1
ubuntu ~/docker $ docker-compose ps
      Name         Command   State    Ports

Tags

 Linux  Docker