Goals

Learn about the concept of containers and their applications in development and deployment of software. Use Docker to create and launch containers.

Examples

Exercises

Introduction

What are containers?

Containers and Virtual Machines

Containers are an abstraction at the app layer. A container engine allows to run multiple containers on the same machine. Each container shares the OS kernel with other containers. A container is "just a process".

Virtual Machines are an abstraction of physical hardware. A hypervisor allows to run multiple VMs on a single machine. Each VM includes a full copy of an operating system.

Docker: What is a container?

Docker: What is a container?

Example

To start a container we can use the run command. It’s easy to spawn multiple containers and they start instantly:

docker run -ti alpine

Resource Isolation

A major feature of containers is their resource isolation. When you start a container, the container has its own:

File System It does not see any files outside the container
Network Stack It can not reach other containers via network
Process List It does not see any other processes outside the container
Memory Limits It is only allowed to use a limited amount of memory
CPU Limits It is only allowed to use a limited amount of CPU

To enable containers to cooperate, files, networks and processes can explicitly be shared.

Example

Again, we start a new container:

docker run -ti alpine