Exercise 0: Getting started

In this section you will install Docker (or log in to one of my cloud servers).

Installing Docker

You have two choices for using Docker today:

  • You can install Docker on your laptop
  • Or you can SSH into one of my cloud servers, which already have Docker installed

I generally recommend trying to install Docker on your laptop first. If you encounter problems, you should just switch to one of the cloud servers instead of wasting time troubleshooting your installation.

Cloud server

Cloud server user chat room for today: https://gitter.im/atbaker/oscon-cloud-users

Warning

These cloud servers are only available to students at my in-person workshops.

If you want to create your own cloud server for this tutorial, here are a couple options:

Use the same AMI I used for my tutorials

Log in to your Amazon Web Services console, go to the EC2 service, and launch a new instance.

On the first screen, select “Community AMIs” from the sidebar and search for “oscon-docker-tutorial”. Click “Select”.

Choose a t2.medium instance, then keep clicking “Next” until you reach step 6 - “Configure Security Group”.

Make sure the security group you choose is one that allows all traffic to your instance. That’s the easiest setting for a tutorial server (but definitely unacceptable for a production server).

Click “Review and launch” and then “Launch”. In a few moments your server will be ready to go with Docker, docker-compose, and my Imgur uploader already installed.

Use a DigitalOcean server

Another easy way to get a Docker-ready server is DigitalOcean - using my link will get you some free credit.

Look for the Docker image when starting a new droplet:

../_images/digitalocean_droplet.png

You will also need to install my imgur-uploader command line utility to complete Exercise 1.

If you don’t want to waste time installing Docker on your laptop (or if the wifi isn’t good) and you are comfortable editing files in a terminal session (using something like vim or nano), then you can use one of my cloud servers for today’s session.

  1. Go to this Google Sheet and write your name in the column called Being used by
  2. Download the docker_tutorial.pem identity file (you may also need to chmod 600 on Mac or Linux)
  3. Connect to the server using the command in the Login command column (if you’re using Windows, follow these instructions using PuTTY)

Note

A couple other things to remember when using my cloud server today:

  • Keep in mind that when accessing your containers through a browser, you will need to use the server hostname from the spreadsheet instead of localhost
  • These servers will be terminated shortly after the end of our session, so be sure to save anything you want to keep before you leave today
  • Please don’t do anything irresponsible with them. I live in DC so I wouldn’t get far if the Feds came after me :P

The server already has Docker installed, so you can proceed to the Your first Docker command section below.

Linux

Linux user chat room for today: https://gitter.im/atbaker/oscon-linux-users

Check out the list of Linux distributions here: http://docs.docker.com/engine/installation/. Find yours and follow the instructions to install Docker.

Be sure to follow the instructions carefully. For various reasons, installing Docker directly from your distro’s package manager usually doesn’t work.

Note

By default, Docker commands will require sudo to run. If this bothers you, look for extra instructions on your distro’s installation page to create a docker user group to fix this.

After Docker finishes installing, you should start on the Your first Docker command section below.

Mac OS X

Mac user chat room for today: https://gitter.im/atbaker/oscon-mac-users

Follow the instructions here to install Docker on OS X. When you get to the end of the install wizard, choose “Docker Quickstart Terminal” - not “Kitematic”.

You can stop following the instructions when you get to the “Where to go next” section.

Note

A few other things to remember when working with Docker on OS X:

  • You must run eval "$(docker-machine env default)" in every new terminal session to connect your Mac Docker client to the VM’s Docker daemon
  • When accessing your containers through a browser, you will need to reference them by the IP address supplied by the docker-machine ip default command, not localhost

After Docker finishes installing, you should start on the Your first Docker command section below.

Windows

Windows user chat room for today: https://gitter.im/atbaker/oscon-windows-users

Follow these instructions to install Docker. When you get to the end of the install wizard, choose “Docker Quickstart Terminal” - not “Kitematic”.

Note

For the rest of the tutorial, keep in mind that when accessing your containers through a browser, you will need to use the IP address supplied by the docker-machine ip default command, not localhost.

You can stop following the instructions when you get to the “Further Details” section.

After Docker finishes installing, you should start on the Your first Docker command section below.

Your first Docker command

If you haven’t already, try running a command with Docker:

docker run hello-world

Your terminal output should look like this:

Unable to find image 'hello-world:latest' locally
latest: Pulling from hello-world

a8219747be10: Pull complete
...
Status: Downloaded newer image for hello-world:latest
Hello from Docker.
This message shows that your installation appears to be working correctly.

When Docker is installed on your machine and working properly, proceed to Exercise 1: Fire it up!.