Knowing Docker As A Developer

Victor Bruce-Crabbe
4 min readApr 16, 2019

--

Build once, run anywhere

Back at the University, I had to take a course called Applied IT Programming. In that course, we had to learn PHP as a programming language together with MySQL as the database. The first step for most of us was to install PHP and MySQL on our machine to start writing some PHP codes and SQL statements. A lot of my colleagues got frustrated at the initial stage and gave up because some could not get PHP to run, or MySQL to start; It was hell❗️

The problem got worse when one wanted to run code from one machine environment to another. Some of the issues were either the PHP version was different or the Operating Systems were not the same. In spite of that, a colleague of mine never liked PHP until now 😂.

The problem wasn’t the language, but rather the environment in which the code was run. People have different working environments and this a major problem, especially when working in a team.

Docker

Docker comes in to solve the problem by creating a container that provides your application with everything it needs to run: code, runtime, system tools, and libraries. So instead of building an application on one machine and try and mimic the environment of another machine, especially if it is a different operating system. Docker completely gets rid of that.

I will get into the terminologies very soon, but let’s look at some of the benefits of developing the docker way.

Benefits of using Docker

  • Stop wasting hours trying to set up development environments, onboard faster, and spin up new instances (containers) and make copies of production code to run locally
  • Eliminate environment inconsistencies and the “works on my machine” problem by packaging the application, configs, and dependencies into an isolated container
  • Enable polyglot development (writing code in multiple languages to capture additional functionality and efficiency not available in a single language.

Most people refer Docker to be a lightweight VM(Virtual Machine) due to the similarities between containers and virtual machines. Thus, both containers and virtual machines isolate applications and it’s dependencies into a self-contained unit and also removes the physical hardware allowing for the efficient use of computer resources.

The main difference that separates the two is the architectural structure.

The architectural structure of Virtual Machines and Containers

Virtual Machine

A virtual machine is an emulation of a physical machine that executes applications or programs like a real computer. It runs on top of physical computers with the help of a software called hypervisor.

A hypervisor is a piece of software that virtual machines run on. There are two types of hypervisors. We have a type 1 hypervisor and a type 2 hypervisor.

Type 1 Hypervisor: has a direct link to the physical machine’s hardware (laptop, server, etc. ). Examples are VMware ESXi, Proxmox, XCP-ng, etc.

Type 2 Hypervisor: runs an application on the host operating system. Eg Virtual Box or VMWare.

Container

A container in the case of Docker containers is a runtime instance of an image — what the image becomes in memory when executed. Containers do not need a hypervisor to run on. Containers run directly on the host machine’s hardware hence having access to the host machine resources such as CPU, memory, disk space, etc.

Image

An image is an executable package that includes everything needed for an application to run. That is the code, a runtime, libraries, environment variables, and configuration files.

Docker Engine

In docker, the docker engine is a layer that runs on the host operating system. It consists of a Docker daemon, Docker CLI, and a REST API.

  • Docker daemon: is a service that runs on a host operating system.
  • Docker CLI: is a command line tool that allows you to talk to the docker daemon directly.
  • REST API: it allows a number of tools (third-party applications) to talk to the daemon through the API. The most widespread tool is Docker CLI.

To find out more about, the best place is to checkout docker’s official documentation (https://docs.docker.com/).

Thanks for your time 🙏🏽. Please let me know if there are any suggestions or mistakes that need correction in the comment section below.

--

--

Victor Bruce-Crabbe
Victor Bruce-Crabbe

Written by Victor Bruce-Crabbe

[Available for Hire]. I share my learning experience through writing based on what I will want to read when learning a new concept to help others.

No responses yet