A Short Explanation of What Docker and Containers Are

An explanation of the core concepts in Docker

I will make an analogy with software development. Here we make a simple C++ project.

$ mkdir my_project
$ cd my_project
$ touch Makefile
$ touch foobar.cpp
$ make

Container Analogy

Lets do something analogous in docker. We create a project folder, which is used to create an container image (not an executable).

$ mkdir my_image
$ cd my_image
$ touch Dockerfile
$ touch foobar.json


Like a a Makefile, the Dockerfile contains a set of instructions for how to build a docker image. Typically a lot of these instructions will involve downloading files and packages from the internet and run configuration commands. So there will not be that many files like foobar.json. Unlike our app development example these files will mainly be data and configuration files and not source code.


In the project directory we can create a docker image with:

$ docker build -t my_image:2.0 .

How is an image different from an executable?

First of all it does not represent a single file. However when we build application we also don’t just create single files. There are multiple libraries and resource files created as well. On e.g. a Mac this all get collected into a directory we call a bundle. So an application on the mac such as Mail.app is actually just a directory containing executables, libraries and resource files needed to run the Mail application.


The name container makes it easy to think of it as a database or storage primarily. However containers are instances of images, just like a process is an instance of an executable.

$ docker run my_image:2.0
$ docker run --name my_container my_image:2.0

How is a container different from a process?

You can think of a container as a potentially a collection of several processes. They exist in a namespace so they can’t see the all the other processes on your computer. Also they can’t see files or folders outside the container. This is what tricks the processes into thinking they are on a different computer.

The Purpose of Container Technology like Docker

We already have virtual machines which can simulate whole computers where you can install any operating system. That has a noticeable performance overhead, as a whole computer needs to be simulated.

Geek dad, living in Oslo, Norway with passion for UX, Julia programming, science, teaching, reading and writing.