Part 2 : Remote container on server



This part will show how to use code-server container remotely on a server. As we are testing an optimisation lecture, this can be usefull if your laptop is not powerful enough or if you want to test hardware your latop does not have (NUMA or GPU for example).



First, we have to jump on the server we want :
ssh -L 127.0.0.1:8080:127.0.0.1:8080 R]@R]


The option -L allows to foreward ports through ssh. We have to use it to redirect the code-server on the distant server to our laptop. By doing this, the url http://127.0.0.1:8080/**on the server will be redirected as the same http://127.0.0.1:8080/**on our laptop.

Then, go to the directory you want to follow the lecture.

Then, let's get the container (the same as local lecture) :
apptainer pull docker://gitlab-registry.in2p3.fr/cta-lapp/cours/introduction_cpp_algorithms/introduction_cpp_algorithms_alpine_micromamba_code_server:latest


This will create a introduction_cpp_algorithms_alpine_micromamba_code_server_latest.sif file of 310 MB. It contains :
  • All the lecture dependencies
  • All the lecture examples
  • A readme.md with link to the lecture content
  • A code-server which allows to follow the lecture directly inside a browser
For this demo, we will use apptainer. Since we will compile examples we will bind an extra directory to save performance results. It's possible to add --writable-tmpfs option to tell apptainer the container is writable but it is quite limited by default so we will still have to bind directory.

Let's create a build directory :
mkdir build


Now, we can start the container :
apptainer run --bind build:/build --writable-tmpfs introduction_cpp_algorithms_alpine_micromamba_code_server_latest.sif micromamba run code-server


Then, we can connect to http://127.0.0.1:8080/**.If you connect for the first time, code-server will ask you a password which is writen inside a configuration file in your home. It will tell you where it gets the password from anyway.

You can get the configuration with the following command :
cat ~/.config/code-server/config.yaml


Now, you can follow the lecture. All the examples are stored in the
Examples directory. We can check the SimpleDotProduct :

First, let's go into the
/build directory :
cd /build


Then, we can call cmake :
cmake /home/jovyan/Examples/SimpleDotProduct


Then, we can compile :
make


Finally we call the executable :
./simple_dot_product


If you started the container with the option
--writable-tmpfs, you can update the main.cpp, recompile it and see the changes in the result.