Let's talk about containers

Overview

Teaching: 0 min
Exercises: 0 min
Questions
  • Key question

Objectives
  • First objective.

What are containers

Before discussing the technical details of what a container is, let’s discuss the purpose of a container.

A container allows us to:

For those familiar with virtual machines (VMs), this description will sound quite similar. At the core, containers and VMs provide the same function; isolated, reproducable environments. However, there are some important differences:

Container vs. VM

The key difference is in what each system virtualises; VMs virtualise hardware whereas containers virtualise operating systems.

Containers:

Virutal Machines:

Docker

Docker Logo

There are a number of options for creating, deploying, and using containers, but by far the most common and widely-used is Docker.

Docker provides a framework that allows users to create, share, and manage containers. There are few key concepts to working with Docker containers:

Docker Workflow

Docker Basics

The focus of this course is not to be a Docker tutorial; however, it is beneficial to cover somee of the more common Docker commands. Docker provides a CLI that lets users interact with the Docker client, which sends the commands to the Docker engine where they are interpreted and executed.

docker help

docker COMMAND --help

docker run -i -t ubuntu

docker run ubuntu cat /etc/lsb-release

docker ps

docker images

docker pull alpine

docker pull alpine:3.1

docker build my_image .

docker push my_image

This is just a quick listing of the common Docker commands you’d use in everyday use. There are a large number of excellent online tutorials and user guides if you wish to know more about advanced features of Docker.

Containers and HPC

Containers & HPC

Why can’t we just run Docker on Magnus? At present, Docker presents several challenges for running in a shared, HPC environment:

Several options have been developed to enable containers on HPC systems.

Shifter

Shifter

Shifter is a container technology developed by NERSC that enables the use of containers on HPC systems, particularly Cray systems. At its core it’s meant to function just like Docker.

Shifter is composed of two parts:

Beyond allowing users to run Docker images on a Cray HPC system, Shifter also provides application performance in certain cases. Python applications in particular benefit from running inside a container. Below are the results of running an application called Pynamic in several modes on different Pawsey filesystems. Pynamic is a synthetic Python code that creates a large number of shared object files, each with a random number of mathematical functions. The results show running Pynamic on several parallel filesytems, as well as copying the Pynamic libraries to a local ramdisk, and finally running directly in a container with Shifter:

Pyanmic Benchmark

Using Shifter is outside the scope of this course, but if you wish to use it, see the following resources:

Shifter at Pawsey

Using Shifter at NERSC

Pawsey currently has deployed Shifter on both of its Cray systems, Magnus and Galaxy. For those who wish to use containers on Zeus, there is another option:

Singularity

Singularity

Singularity is another container technology designed for HPC use. It functions much the same as Shifter, in that it provides a framework for safely and securely using containers in a shared, HPC environment.

Singularity works by virtualising namespaces, and it only does so with the namespaces it started with, meaning a user has the exact same permissions inside a container as he or she would outside of the container.

There are number of important differences between Shifter and Singularity:

Docker Interoperability

MPI Support

GPU Support Singularity supports GPUs by default, and a version of Shifter developed by CSCS has GPU support, as well.

Singularity has a similar CLI to Docker:

singularity exec

singularity build <target> <output container>

singularity pull

singularity run

Key Points

  • First key point.