Explaining Docker Image

The aim of this page📝 is to explain the concept of docker image.

Pavol Kutaj
2 min readOct 5, 2022

DEFINITION

  • software object
  • contained within it is a “kind of” snapshot of a full file system
  • including everything necessary to launch a viable virtual server
  • and the image itself (not container!), no matter what the structure, is immutable (should never change)
  • in a lifecycle of a docker application lifecycle, it belongs to the build_time
APP:   dockerfile  →   image         →   container
-----------------------------------------------------
TIME: code → build_time → run_time

STRUCTURE

  • Docker image consists of 3 layers, starting from the bottom:
  1. WRITABLE record of ongoing activity is saved 🠉
  2. APPS: dependencies, DBs, your programs 🠉
  3. OS: just a basic OS such as a minimalistic Alpine Linux

PURPOSE

BENEFIT#1: SPEED

  • image layers outlined above (os/apps/writeable) are modular, i.e. function independently from each other
  • from that it follows that components of each of the three layers can be shared among multiple images that are hosted by the same/shared instance of a Docker engine
  • this means that pulling/building new images can sometimes mean adding very little new data (you share OS, share DB and you may just pull several dependencies)
  • …the Docker engine adds only those resources that are not already present on a Docker host

BENEFIT#2: PREDICTABILITY/CONSISTENCY

  • launched containers provide identical environments
  • …no matter a) where they are hosted
  • …no matter b) how many times they were already launched
  • resonant with the Devops Handbook principle asserting to Make Infrastructure Easier to Rebuild than to Repair < The DevOps Handbook < The Technical Practices of Flow
  • great for prod / remote collaboration
  • all the code, and dependencies are there exactly the way you created them
  • much better than painstakingly documented instructions on how to set up the environment
  • much better working when snapshots of virtual machines
  • docker image is the playbook
  • it will reliably deliver exactly what you want it

--

--

Pavol Kutaj

Today I Learnt | Infrastructure Support Engineer at snowplow.io with a passion for cloud infrastructure/terraform/python/docs. More at https://pavol.kutaj.com