Containers, Docker, Kubernetes Flashcards

1
Q

What are containers and what are their advantages over VMs?

A

A lightweight alternative to VMs that sits on top of the kernel of a host OS
- they start almost immediately
- less resource intensive
- easier to create and manage
- mostly same benefits of VMs but also remove drawbacks of VMs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do containers provide encapsulation?

A
  • they encapsulate an application and it’s dependencies
  • ‘code running inside a container is really just running on the host OS but shielded from the rest of the OS
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Name some popular containerisation tools:

A

Docker, PodMan, Kubernetes, OpenShift

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Describe the tech stack for containers

A

Layers:
Application1 Application2 Application3
Container1 Container2 Container3
Linux Kernel
Hardware

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Describe the tech stack for containers + virtualisation

A
  • run containers on the VMs, these have a virtual linux kernel which the containers run on.

Layers:
Application1 Application2 Application3
Container1 Container2 Container3
VM1 VM2
Hypervisor
Hardware

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Why would you use containers + virtualisation despite the fact that VMs are resource intensive?

A
  • It means the only permanent piece of hardware is the bare metal server
  • so everything can be completely changed. One day you can run a kubernetes cluster, the next you can run a web server, without having to uninstall the linux kernel from the server.
  • this is a very scalable method (as easier to spin up than VMs)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is Docker?

How does it work?

A
  • The most well known solution for containerisation
  • containers are created from images which are specified in Dockerfiles. e.g. an Ubuntu image
  • always start from an existing image
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the command for downloading the latest ubuntu image from the main docker image repository, Docker Hub?

What is the command for running the downloaded image in a container?

A

docker pull ubuntu:latest

docker run -it ubuntu:latest /bin/bash
// this runs a new container and starts a bash shell with an interactive terminal (interactive mode)
// there’s no boot process for containers because they sit on top of the linux kernel

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

If the code to load the latest ubuntu image and run it is saved in a file called Dockerfile, what commands are used to build and run the docker container?

A

docker build -t hello - world .
// builds the docker image
// -t specifies to tag a name “hello-world” to the image
// . tells docker to use the current directory, thus docker looks for the dockerfile in this directory to define what goes into the image

docker run hello - world
// runs the docker container

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the key dockerfile elements?

A

*Base image: specifies another image on which the new image is being built
* instructions: defines steps to build the image e.g. installing dependencies, files and the environment configuration
* commands: execute commands within the image during the build process
* exposed ports: specify which ports should be exposed when running a container from the image
*endpoint: define the command to be executed when a container is started from the image

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Describe docker layers:

A
  • docker images are made up of read only layers, each representing a dockerfile instruction
  • Each layer represents a set of file system changes (like adding files or installing software)
  • so a layer contains only differences from the previous layer
  • layers are stacked on top of each other to form a base for a containers file system
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Why does Docker uses a layered architecture?

A

To make image creation efficient and to support caching and reuse.
- If nothing changes in a layer’s instruction or the ones before it, Docker reuses the cached version instead of rebuilding it.
- This speeds up image builds significantly.
- If multiple images share common base layers (like python:3.11), Docker only stores one copy of that layer.
- This saves disk space and improves efficiency.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

List 5 docker CLI commands and explain what they do:

A

docker ps //lists all running containers

docker ps -a //lists all containers, including stopped ones

docker stop [ CONTAINER ID ] //stops a running container

docker rm [ CONTAINER ID ] //removes a stopped container

docker rmi ubuntu:latest // removes an image

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Explain container isolation:

A
  • containers create an illusion of separate OS’ on top of a host OS
  • a container is just a collection of processing running on the host OS
  • the linux kernel isolates the containers processes on the host OS, as well as providing resource management and file system abstraction
  • Each container runs in its own set of namespaces, providing a somewhat isolated environment.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Describe the use of the linux kernel in regard to containerisation:

A

the linux kernel enables:
*Namespaces: that isolate system resources for a collection of processes
* control groups (cgroups): manages resources allocation and usage for containers
*union file systems: allow containers to share a read only base file system, maintaining separate writable layers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Describe linux namespaces:

A

*these isolate process groups, providing each container with it’s own view of system resources such as network, processes and mount points
*ensure each set of processes sees its own isolated instance of a global resource.

17
Q

What are the 6 types of linux namespaces:

A

*PID: isolates the process ID number space: for a running container, shows only processes running in a specific namespace (won’t see processes for other containers with different namespaces)
*NET: the network namespace which virtualises the network stack. provides different network stacks for different containers.
*MNT: manages mount points (file systems)
*UTS: unix time sharing isoles host and domain names
*IPC: isolates inter process communication
*USER: provides privilege isolation and user identification segregation

18
Q

Describe Control groups (cgroups)

A
  • they manage resource allocation for containers
  • limit/monitor resources (CPU, memory, disk, I/O) that a container uses
  • ensures containers can’t monopolise resources
19
Q

Describe union file systems:

A
  • provide a layered file system
  • allows containers to share the kernel and a read-only base file system while maintaining separate writable layers for each container
20
Q

Explain how containers are useful for the proliferation of services?

A
  • they’re so lightweight running a single process in a container isn’t inefficient
  • they don’t require a lot of manual config like servers to do run applications on
  • they are a solution for deploying services, so companies with large cloud computing resources can run billions of them
21
Q

What is Kubernetes?

A

The most popular piece of container orchestration software that manages containers at a scale in the cloud.
- open source, automates deployment, scaling and operation of containers

22
Q

What are microservices?

A

a style of software architecture that can take advantage of the ability to run large numbers of containers

23
Q

What is orchestration software?

A

Sits on top of data centre hardware providing:
- deployment of applications on the data centre
- scaling of applications resources on demand
- self-healing: restarting applications that have crashes
- zero downtime updates and rollbacks

24
Q

Describe the advantages of kubernetes:

A
  • runs on DC servers abstracting away complexity of underlying hardware to provide a simple interface for running containers, known as OS for DCs
  • Kubernetes does hardware difficulty abstraction for DCs full of servers.
25
Describe the history of Kubernetes:
- designed by Google, built in response to AWS - Using kubernetes, Google's cloud team aimed to make cloud software more portable between different cloud providers - built using experience of inhouse systems Borg and Omega
26
Describe Borg and Omega:
- Google's in-house cluster management systems, running billions of containers across many DCs - Borg came first then Omega succeeded it - influenced design of kubernetes
27
describe kubernetes and docker:
- kubernetes once used docker as it's container run time - now more flexible and supports other runtimes (even multiple runtimes within one kubernetes cluster) - default container runtime is now Containerd - kubernetes runs anything that adheres to the OCI standard
28
What are CRI and OCI?
Container Runtime interface, allows kubernetes to have plugable container runtimes - this provides better isolation and performance over docker - the Open Container Initiative is a standard for container runtimes
29
What is Containerd?
A stripped down version of docker, full supports docker containers but is more lightweight
30
Describe Microservices as opposed to monoliths
- Kubernetes enables containers to be easy to spin up, and deployed in large volumes. - Instead of deploying a single application in a single container, we can deploy applications as a collection of containers. This is the idea behind microservices. - Each container runs a single service, and the application is made up of many services. - because containers are so easy to deploy, they can provide small (micro) bits of functionality as services (hence the name microservices). - This replaces the old architectures, where applications were often built as monoliths i.e. large codebases which packaged the entire application as a single inter-woven tangle of code (often amounting to millions of lines of code).