Dial D for Docker: Part 1 — Installation and commands

Rahul
Lethal Brains
Published in
5 min readJun 20, 2017

--

Intro to this series

I was first introduced to docker at an AWS DevDay technical event few years back. I have been learning and using docker since then and have found out immense material out here in the web but was never satisfied with a single material source. With latest changes in the docker community, I thought I can create a blog series explaining all that I have learnt about docker.

I will be covering the basics of docker from installation, deep diving into containers and images, digging into docker compose, service & swarm, deployment as EC2 container service, how to deploy microservices using Docker and a lot more.

What is docker and how is it different from a VM

Me: Hello Tom. Whats up!
Tom: Hi Rahul. I have been reading about Docker. Do you know what is it about and how is it different from a VM?
Me: Sure. Docker is a software [..spits out the typical wiki description..].
Tom: (With an annoyed look) I read that in wikipedia. Got anything else? Probably with an example.
Me: Okay. How about this. David and Goliath were chefs residing next to each other at an apartment. They decided to throw a party and each one wanted to better the other. Both were good at cooking but had no sense of decorations. So Goliath decided to call VM1 party decorators but to his dismay, VM1 decorators came with their own fake walls and ceiling to create a separate party room in Goliath’s living room. Once setup, it occupied most of Goliath’s living room space. Though the decorations were nice, Goliath found it laborious to move the food in and out of the party room. VM1’s drinks and cups decoration was very dull, so Goliath decided to call VM2 decorators for this purpose. VM2 came with their own walls and ceiling to Goliath’s horror. Somehow, they did setup another party room but it occupied the rest of the living room and a part of the kitchen. Communication between the rooms had become horrendous and food distribution had become disastrous. So Goliath instead on focusing on what he does the best(cooking), he spent time on organizing everything else.

Me: David on the other hand, dialed up Docker1 decorators who used David’s living room for decoration and items within the house to make a nice theme. Docker1 guys were nice enough to call Docker2 and Docker3 for decorating cups and ice creams and all three were easily accommodating. David’s cooking was worldly and the party was a blast. So on the technical terms, Docker engine runs on top of the host’s Kernel making the docker container fast and lightweight with shared components(binaries, libraries) while the Virtual machines run their own unique operator system with its own memory management installed with the associated overhead of virtual device drivers and have individual binaries, libraries and applications making them gigabytes in size.

The above conversation would have given you a basic idea about Docker and how it is different from a VM. Instead of providing you with a definition of Docker, I prefer we go along with the tutorial and understand what Docker is and what it is capable of.

Installation

OSX:
You can install Docker using Docker for Mac

Linux:
You can use Docker’s automated script to add their repository and install all dependencies: curl -sSL https://get.docker.com/ | sh

Windows 10(Pro and Enterprise editions):
You can install Docker for Windows from the Docker Store

Windows 7, 8, or 10 Home Edition:
you’ll need to install the Docker Toolbox

Docker Toolbox is a slightly different approach to using Docker with a VirtualBox VM. This means Docker will be running in a Virtual Machine that sits behind the IP of your OS, and uses NAT to access the internet.

Docker Versioning and new changes:

On Feb 8th 2017, version 1.13.1 of Docker was released and the release of Docker on Mar 1st 2017 had version 17.03. This change was to provide Docker with a YY.MM versioning scheme.

  • Their release also has Stable(read as: slower) and Edge(read as: faster) options.
  • Docker Engine (the free one) is now Docker CE (Community Edition)
  • Docker Data Center is now Docker EE (Enterprise Edition)
Docker lifecycle released by the docker team

Docker Commands:

Once Docker is installed you would have access to the docker command in your cli. Type docker in your cli tool to verify the same. Then lets check what version of docker we have installed using the command docker version. You can also try out docker info for more details. We will analyze the content in a later blog. For now just play around.

When you hit docker in the cli, you would notice 3 segments

  1. Options
  2. Management Commands
  3. Commands

These three segments combine to form the actual docker commands. A typical docker command line structure would be

docker <management command><command>(options)

Lets get our hands dirty and try out few commands. Lets run an nginx container in our local machine. Use the following command

docker container run --publish 80:80 --detach nginx

Since this is your first time running this command, it might take around a minute. Once its done, goto localhost in your browser and you will notice nginx running in port 80. You can also find the container status by running the following command

docker container ls

In the following segment, I will explain what these commands are. What does a container mean? What is an image? How are they related and we can play around more with containers and images.

Guys, if you are looking for any particular topic to be covered, let me know in the comments, I will add it part of the series.

This article is a part of docker series Dial D for Docker. You can find the next article in the following link

--

--

AWS certified Solution Architect | Node.js - Machine learning Engineer | Amateur photographer