Docker instructions

All compilers required or suggested by the “Distributed Computing over the Internet” class have been installed and set up in a docker image, so that you don’t have to download, compile, install and set them up in your machine.

The following are the instructions to download and work with a docker image. Notice that working with this image is not required, but it is suggested as it removes you from the burden to have to figure out how to compile the compilers.

Docker installation

First of all, you must install docker in your machine. Make sure the docker deamon has been enabled and is running, all required user configurations have been set up to be able to execute docker from your user terminal.

You can check your installation by running the following command line:

docker run -it --rm archlinux bash -c "echo hello world"

If you see “hello world” in the terminal, everything is working fine.

You can remove the archlinux image (about 400MB) from your system by running:

docker rmi archlinux

Downloading docker image and creating container

The first example in this guide downloaded an image, created a container based on the image, ran a bash script, and deleted the container once it closed. You probably don’t want this. We want to preserve the changes in the container. So, instead, what you are going to do is to download the image first and then you will create a container:

docker pull helq/rpi-csci6500:default
docker create -t -i --name distcomp -w /root helq/rpi-csci6500:default /bin/bash

Running container

Once you have the container, you can run and log in it with:

docker start -i -a distcomp

You should land into a bash linux environment. You can do whatever you want in here. You can create, delete, download files and everything you can do as a root user inside the docker image.

Once you log out of the bash session (typing exit or Ctrl+D), the container will be stopped and any changes will remain in the container.

If logging into a system using the docker commands is a bit annoying, you can set up an SSH connection to the image. (This is left out the scope of this small guide. It is just a suggestion for those of you who are more adventurous or preffer to work with SSH.)

Compiling examples

Once you run the container and log in, you can then start to play around with the compilers. The following are the instructions to run code for each one of the supported languages in the class.

Pict

For these examples, we will take the example code accessible in a previous iteration of the class.

Dowload the code inside your docker container:

wget https://www.cs.rpi.edu/academics/courses/spring19/dci/code/pict/bool.pi

Compile it:

pict bool.pi -o bool

Run it:

./bool

SALSA

To download and uncompress file:

wget https://www.cs.rpi.edu/academics/courses/spring19/dci/code/salsa/salsa_samples.zip
unzip salsa_samples.zip helloworld/HelloWorld.salsa

To compile:

java salsac.SalsaCompiler helloworld/HelloWorld.salsa
javac helloworld/*.java

Note: if you want to use SALSA Lite instead of SALSA replace salsac.SalsaCompiler for salsa_lite.core.compiler.SalsaCompiler.

To run:

java -cp "$CLASSPATH:." helloworld.HelloWorld

JoCaml

To download:

wget https://www.cs.rpi.edu/academics/courses/spring19/dci/code/jocaml/sn.ml

To compile and run:

jocamlc sn.ml -o sn
./sn

Or, alternatively, to run the interpreter on the example without compilation:

jocaml sn.ml

Copying data to and from container

Docker comes with a tool to copy to and from any container.

From the local filesystem to the container:

docker cp path/to/file-or-dir distcomp:destination/path

From the container to the local filesystem:

docker cp distcomp:path/to/file-or-dir destination/path

Deleting containers and images

Docker images and containers might take gigabytes of space in the computer. You can delete them at any point in time, but beware that you will delete everything there is inside the containers.

To check for all containers in your system:

docker ps -a

To delete a container:

docker rm <CONTAINER ID>

To check for images:

docker images

To delete an image:

docker rmi <IMAGE NAME>