still writing authored by Stefano Bagnasco's avatar Stefano Bagnasco
......@@ -5,6 +5,8 @@ The OCCAM user interface is based on GitLab; we encourage use of the OCCAM GitLa
**Please note that directly running a container is currently supported only for single-node, single-step computations. Multi-node MPI applications and pipelines need some more massaging.**
**Please note, again, that this is not a full Docker tutorial but only a step-by-step example on how to build, upload and run a container on OCCAM. Please refere to the Docker official documentation for more information.**
## Obtaining an account
You already have an account on the system, otherwise you would not be able to see this page.
In order to be able to connect via ssh on the access node, and for all the OCCAM machinery to know you, you still need to upload an ssh key to you user profile. Please go to https://occam-00.ph.unito.it/profile/keys. There you will find detailed instructions.
......@@ -18,7 +20,7 @@ There are several implementations of software containers; in OCCAM we currently
In order to build and upload the image, you will have to install Docker in your machine. Please download and install from https://store.docker.com/search?offering=community&type=edition; yes, you can build and run Linux containers on MacOS and Windows, and they will run on OCCAM.
## Image build workflow
## OCCAM workflow
The basic workflow is the following:
1. You build and test the image on your machine by writinga a ``Dockerfile`` and using standard Docker commands;
......@@ -38,4 +40,62 @@ First, you will need to copy all the relevant files to a directory in your machi
If you're familiar with git, you can get both the files (script and Dockerfile) by cloning this project's repository:
```bash
git clone git@occam-00.ph.unito.it:bagnasco/docker-example.git
```
Otherwise, you can simply download them with wget or curl, for example
```bash
mkdir docker-example
cd docker-example
wget https://occam-00.ph.unito.it/bagnasco/docker-example/blob/master/Dockerfile
wget https://occam-00.ph.unito.it/bagnasco/docker-example/blob/master/mandelbrot.py
```
Take your time to peruse the Dockerfile before building; it is described in some detail [here](dockerfile), and the full reference is at https://docs.docker.com/engine/reference/builder/.
Now you can build the image with
```bash
docker build -t <username>/mandelbrot .
```
You will see that Docker downloads the base image, then step-by-step does all the operations described in the Dockerfile. ``<username>/mandelbrot`` is the name you give to the image. Please replace <username> with your OCCAM username. Docker caches everything that can be cached, so if you change something in the Dockerfile and build again it will not, for example, download again the base image.
At this point, you can use ``docker images`` to see the newly-built image (as well as all other previously built images, if any), and ``docker run`` to test the container:
```bash
docker run -ti --rm --volume $PWD:$PWD --workdir $PWD bagnasco/docker-example
```
In our convention, the software must read and write to the current directory from which the container is launched. This is exposed inside the container by the ``--volume $PWD:$PWD --workdir $PWD`` options to the command. You can find the full ``docker run`` reference at https://docs.docker.com/engine/reference/run/.
The output shoud be something like
```
Computing...
Drawing...
Done.
```
and you should find a new file ``mandelbrot.png`` in the current directory. You can pass arguments to the script, that will override the defaults defined in the Dockerfile, by adding them to the command line:
```bash
docker run -ti --rm --volume $PWD:$PWD --workdir $PWD bagnasco/docker-example 10 10. 101 301
```
## Uploading the image
In order to run on OCCAM, you need to upload the image to the image registry.
First you will need to login to the GitLab repository, using your OCCAM username and password:
```bash
docker login occam-00.ph.unito.it:5000
```
Then you can build it with a name including the registry name and push it:
```bash
docker build -t occam-00.ph.unito.it:5000/<username>/mandelbrot .
docker push occam-00.ph.unito.it:5000/<username>/mandelbrot
```