Prep

Containers

Learning Objectives

A container is a kind of sandboxed process on a computer that is isolated from all other processes, unless specifically allowed.

Containers have an isolated filesystem. This filesystem is provided by a container image. Since the image contains the container’s filesystem, it must contain everything needed to run an application: all dependencies, configurations, scripts, binaries, & other files or data. The image also contains other configuration for the container, such as environment variables, a default command to run, and other metadata.

By building images, and then running containers from the image, we can package whole applications in a way that is transferrable (we can create them completely separately from running them) and highly reproducible. Both of these are very important in a production environment.

The isolation and security allows us to run many containers simultaneously on a host computer. Containers are lightweight and contain everything needed to run the application, so we do not need to rely on what is currently installed on the host (and don’t need to worry that it may change between deployments). We can easily share containers while we work, and be sure that everyone we share with gets the same container that works in the same way.

This makes containers & images a very desirable way to build and deploy applications. They are commonly used at many companies.

To summarize, a container:

  • is a runnable instance of an image. We can create, start, stop, move, or delete containers
  • can be run on local machines, virtual machines or deployed to the cloud
  • is portable (can be run on any OS)
  • is isolated from other containers and runs its own software, binaries, and configurations

For even more on containers, you can read Julia Evan’s fantastic guide to What even is a container?.

πŸ“Note

In this track, we’ll use the terms containerise and dockerise interchangeably to mean the same thing: making an application run in a container using Docker.

Docker

Learning Objectives

Docker is an open platform for developing, deploying, and running applications, based around containers and images. Docker provides tooling and a platform to manage the lifecycle of our containers:

  • We develop the application and its supporting components using containers.
  • The container becomes the unit for distributing and testing the application.
  • When ready, we deploy the application onto a production environment that will handle real workloads.

This works the same whether the production environment is a local data center, a cloud provider, or a hybrid of the two.

Reading and Tutorial

Read this guide to get an overview of Docker.

To build hands-on familiarity with Docker, complete parts 1, 2 and 3 of this tutorial. Make sure you have met the learning objectives on this page.

Docker (language-specific)

Learning Objectives

For the language you want to work in, find the language-specific tutorial in the list of guides. For example:

  • Go
    • You only need to do steps 1-4, you can skip configuring CI and running containers in Kubernetes.
  • Java
    • You only need to do steps 1-3 - you can skip configuring CI and running containers in Kubernetes.
    • Note that this tutorial uses docker-compose to manage multiple Docker containers - we will learn more about this soon.

Follow the tutorial, and make sure you have met the learning objectives on this page.

Spend some time on these steps, and feel free to complete other tutorials too. It’s very important to grasp the core ideas of containers, images and docker:

  • Docker is a set of tools for managing containers and images.
  • Images are frozen file systems that hold everything a container needs to run.
  • Containers are the running application, based on an image.

Docker Compose

Learning Objectives

Most software systems consist of multiple components (e.g. a frontend, one or more backends, a database, etc). These systems need to be able to talk to each other.

Docker Compose is a tool for running and connecting multiple Docker containers. It uses a config file to define which containers are needed, and how they should be connected.

Exercise

Follow this guide to Docker Compose. Make sure you have me the learning objectives on this page.