@@ -36,7 +36,7 @@ Building an image means picking a base image and adding all the pieces and confi
If the Linux distribution is not important, we suggest using CentOS 7. This is the OS of choice in this example.
First, you will need to copy all the relevant files to a directory in your machine, then write a Dockerfile to tell Docker how to build the container. In this example, the Dockerfile is provided. In this example there is only one file, the Python script that computes the Mandelbrot set, with the unimaginative name of ``mandelbrot.py``
First, you will need to copy all the relevant files to a directory in your machine, then write a Dockerfile to tell Docker how to build the container. In this example, the Dockerfile is provided. In this example there is only one file, the Python script that computes the Mandelbrot set, with the unimaginative name of `mandelbrot.py`.
If you're familiar with git, you can get both the files (script and Dockerfile) by cloning this project's repository:
...
...
@@ -60,15 +60,15 @@ Now you can build the image with
```bash
docker build -t <username>/docker-example .
```
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.
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:
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 <username>/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/.
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 should be something like
...
...
@@ -96,8 +96,21 @@ Then you can build it with a name including the registry name and push it:
If everything went well, you can go to the registry page at https://occam-00.ph.unito.it/<username>/docker-example/container_registry and you will see you image entry. It will be named "latest": you can add version tags to your containers like ``<username>/docker-example:v1``, but the "latest" tag will always be an alias for the, well, latest version built.
If everything went well, you can go to the registry page at https://occam-00.ph.unito.it/\<username\>/docker-example/container_registry and you will see you image entry. It will be named "latest": you can add version tags to your containers like `<username>/docker-example:v1`, but the "latest" tag will always be an alias for the, well, latest version built.
## Running on OCCAM
Now you can login on the access node (currently occam-01.ph.unito.it) and run your image on the cluster. If everything is set up correctly, your ssh key has already been propagated to your home directory on the system, and you should be able to log in without a password:
```
ssh <username>@occam-01.ph.unito.it
```
Once there, create a directory to work in:
```
mkdir docker-example
cd docker-example
```
Please note that for security reasons you are not allowed to directly run Docker on the system; however, some extra machinery under the hood will do so for you.
First of all, you will need to log in to OCCAM also from there, using