1.1. Introduction
Docker is a tool which allows to start containers i.e. lightweight, isolated environments (OS, libraries, configurations)
- You can install Docker for Mac, Windows or Linux: documentation
To work with a container you need an image to start from
Images can be found in public or private repositories:
A container executes one or more processes in its isolated environment
The process might be a daemon e.g. Apache HTTP Server or it can be an interactive terminal
Dockerization advantages:
Quick prototyping and testing
- For example, you can easily spawn multiple versions of PostgreSQL and test your SQL queries against them
Better dissemination
- The product owner can share a Docker image and anyone interested can use it straight away
Enhanced security
- A container is isolated and runs a limited number of processes
- Even if it gets hacked, the rest of the system remains unharmed
Easier maintenance
- The images are usually built in an automatic way via CI/CD pipelines or regularly scheduled jobs
- No matter how complex the environment is, once the image recipe is created all interested users can instantiate containers at will
1.2. IMAS Docker
The IMAS environment is available under a few flavors
The most important is
imas/ual
, which contains Data Dictionary and Access LayerThe images are available in a private Docker registry https://rhus-71.man.poznan.pl, which requires logging in first:
docker login rhus-71.man.poznan.pl
1.2.1. Interactive session
To pull the image:
docker pull rhus-71.man.poznan.pl/imas/ual
To tag the image with shorter name:
docker tag rhus-71.man.poznan.pl/imas/ual imas/ual
To begin an interactive session:
docker run -it imas/ual
-it
stands for--interactive
and--tty
, which allows to establish the session
1.2.2. Running codes in the container
- A collection of simple IMAS codes to start with can be found here: https://github.com/tzok/imas-hello-world
- The examples cover C++, Fortran, Java and Python
- All codes create the
summary
IDS inshot=1
andrun=1
, each with a different value in thecomment
field - There is a helper Python script
python/read.py
which allows to verify correctness of those codes
1.2.2.1. C++
Source code of cpp/hello.cpp
:
#include <UALClasses.h>
#include <pwd.h>
#include <unistd.h>
int main() {
uid_t uid = geteuid();
struct passwd *pw = getpwuid(uid);
IdsNs::IDS ids(1, 1, 0, 0);
ids.createEnv(pw->pw_name, "test", "3");
ids._summary.ids_properties.comment = "Hello World from C++";
ids._summary.ids_properties.homogeneous_time = 1;
ids._summary.time.resize(1);
ids._summary.time(0) = 0.1;
ids._summary.put();
ids.close();
return 0;
}