bagnasco created page: dockerfile authored by Stefano Bagnasco's avatar Stefano Bagnasco
......@@ -58,19 +58,19 @@ Take your time to peruse the Dockerfile before building; it is described in some
Now you can build the image with
```bash
docker build -t <username>/mandelbrot .
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.
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
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/.
The output shoud be something like
The output should be something like
```
Computing...
......@@ -81,21 +81,23 @@ 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
docker run -ti --rm --volume $PWD:$PWD --workdir $PWD <username>/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.
In order to run on OCCAM, you need to upload the image to the image registry. To do so, you need to create a project on GitLab to hold the image (and possibly also all related files, if you choose to do so), by going to https://occam-00.ph.unito.it/projects/new and filling up the form: the project name must match the image name, so in this case it will be "docker-example".
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
```
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