What is Docker?

Docker Terminology

Docker is usually compared to a shipyard dock.  Suppose there are several ships coming to that dock that need cargo loaded onto it.  For this example, we have three types of cargo.  Let’s call them cargo A, cargo B, and cargo C.  This different cargo is put into boxes (containers).  Although you have 3 types of cargo, you may have 10 boxes of cargo A, 20 boxes of cargo B, and 2 boxes of cargo C.


Let’s relate this to computing.

  • The shipyard dock – the whole framework that holds all the cargo and boxes that makes this happen – is Docker.  It can launch an image inside a container and do all sorts of commands to manage these containers.
  • The cargo is called an image, and this is something like a Linux or Windows environment that can run an application.
  • The individual boxes are called containers.  A container can run many different apps within it based on the operating system.


When Would You Use Docker?

It is good for…

  • Deploying an application with the environment
  • Replicating your development environment for other developers to develop/test your application (and using that same environment on a continuous integration server)
  • Managing dependencies
  • It’s FAST!  Unlike VMs, which take a little while to boot up, Docker containers launch in milliseconds/seconds!

Docker is meant to deploy a single application within an environment.  Many applications have several dependencies that can be time-consuming or complicated to setup.  In order to make it work on another person’s machine, you must first go through the laborious and error-prone task of setting up all those dependencies.

For example, suppose you have a Python application that depends on Flask for a webserver and five other Python packages.  Installing them is easy enough… except… oh wait, it requires Python 3.5 or higher.  Oh, and you’re wanting to deploy on a Linux distribution that doesn’t have Python 3.5 in the repos.  You have to compile it from source or find an alternate source that already has it.  That’s a little more complicated than it has to be.  Instead, you can pull an image that already has that entire application and the environment in it.

Rather than…

  • Install Python 3.5 (compile or find an alternate source)
  • Install the required packages
  • Setup any other config files, etc. that may be needed
  • Hope it works, because that new environment hasn’t been tested

You can do this:

  • docker run my-app

And you can do something similar to that one line command… even if you don’t have that image on your computer already!  Docker will download that image and run it.  It can do this for several different environments and applications.

It will take a little more setup for the person developing the image, but, for everyone else, it is a lot easier (and consistent between different applications).

Docker is Like a VM

  • Both simulate an operating system environment.Ubuntu
  • They separate the host (the machine running the VM/container) from the guest (the VM or running container).
  • They can can have their own network/IP address

Docker is Not a VM

  • You can run multiple instances (containers) of the same image (only one instance of a VM).
  • Containers do not save state: this means once it is destroyed and recreated, it loses all the data it used to have!  This is very good for some use cases but can be problematic for others.  To that point…
  • Docker is meant to run a service/single application… not an entire OS.
  • It uses the host’s kernel.  It does not have its own kernel like VMs.
  • Running a container is more lightweight than a VM (thus you can launch a lot more of them than separate VMs).
  • Containers launch much, much more quickly than VMs (generally less than a second or a couple of seconds).

Docker Usage – Coming in a Future Post

A future post will look at running unit tests within a container.  I encourage you to read the documentation and get started with it.  On later version of Linux distributions, it can be installed as a package.  On Windows 7 or Mac, you can use Docker Toolbox (which creates a VM that has Docker in it that can be used from the host OS).  On Windows 10, you can use Docker for Windows (a sample script that installs this automatically can be found from this post).

I hope this proves to be as useful/interesting a tool to you as it has been to me.  It blew my mind the first time I tried it.

One comment:

Leave a Reply

Your email address will not be published. Required fields are marked *