Skip to content

Software Containers

Why Using a Software Container?

A simple and lightweight solution to reproducible science; see "An introduction to Docker for reproducible research" (paper/pre-print)

KRG Use Cases
  • Tutorials
  • GitLab CI/CD
  • Distribution of pre-release software
  • Reproducers of published works

Docker

Level 1: Using Images

You will need to add sudo prior to docker when using Ubuntu

Since docker runs as root (super user), you may need to run sudo docker instead of docker on some operating systems.

  • install docker engine
  • run container by (docker run -it <img>) using a given docker image (<img>, which can be replaced by, e.g., one of the containers of our group):
sudo docker run -it koresearch/qe
docker run -it koresearch/qe
  • one can also share files between the host (your operating system) and the guest (docker image) by mounting the host volume to the guest (see this thread for more information):
sudo docker run -v /host/project_folder:/container/project -it koresearch/qe
docker run -v /host/project_folder:/container/project -it koresearch/qe

Project: Getting KRG Program Environment

Level 2: Building and Managing Images

Build a Docker Image to Dockerhub:

login (one-time) to host and build an image

sudo docker login [registry_host] # when [registry_host] is absent it is assumed to be Dockerhub; you will be prompt for username and password(/token) 
sudo docker build -t [registry_host/]<container-tag> . # build from "Dockerfile" in the current directory
sudo docker push [registry_host/]<container-tag>
docker login [registry_host] # when [registry_host] is absent it is assumed to be Dockerhub; you will be prompt for username and password(/token) 
docker build -t [registry_host/]<container-tag> . # build from "Dockerfile" in the current directory
docker push [registry_host/]<container-tag>
an example

managing images

  • get images from remote registry_host:
    sudo docker pull [registry_host/]<container-tag>
    
  • show existing images
    sudo docker images
    
  • remove an image
    sudo docker rmi <image-id>
    
  • get images from remote registry_host:
    docker pull [registry_host/]<container-tag>
    
  • show existing images
    docker images
    
  • remove an image
    docker rmi <image-id>
    

Other containers exist to address problems of docker

While docker has limitations, it provides a good starting point for building containers. Docker containers that are compliant to the Open Container Initiative can be used with other container technologies (e.g., singularity) to sidestep limitations.

Additional Tutorials

work with local file system

Level 3: More Advance Topics

Using (Private) GitLab Container Registry

sudo docker login registry.gitlab.com
sudo docker build -t registry.gitlab.com/<usr-id>/<proj-id> .
sudo docker push registry.gitlab.com/<usr-id>/<proj-id>
docker login registry.gitlab.com
docker build -t registry.gitlab.com/<usr-id>/<proj-id> .
docker push registry.gitlab.com/<usr-id>/<proj-id>

process handling

  • show existing docker processes
    sudo docker ps
    
  • attach to existing docker processes
    sudo docker attach <process-id>
    
  • show existing docker processes
    docker ps
    
  • attach to existing docker processes
    docker attach <process-id>
    

HPC-Centric Containers

KRG Containers

Development Environment

Applications