Posted 2016-11-17 with tags linux, Docker

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- | 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
  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
docker_my-test_1   /hello    Exit 0

Now that we have successfully launched the test 'hello-world' container, and checked it's status with the 'docker-compose ps' command, we can move on to working with more containers from the official Docker Repositories.

Helpful Links