Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
aelissa committed Jun 9, 2020
1 parent 30e2531 commit 6cc1573
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
7 changes: 6 additions & 1 deletion 06_Docker.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ List available images :
```shell
docker image ls
```
Pull a new image:

```shell
docker pull image-tag
```

See what containers are running (this also shows you the ID and which port is occupying):

Expand Down Expand Up @@ -80,9 +85,9 @@ Other commonly used flags include:
```
Environment variables in linux act as placeholders for information stored within the system that passes data to programs launched in shells. A common environment variable is *HOME* which is associated with the path of your home directory (*/home/your-user*). By adding *-e* to the run command you pass the environment variable to the container where a certain image is running. Cases when this option is necessary will be discussed.

```shell
--publish or -p -> Publish a container’s port(s) to the host (This is key when running server-based application through Docker. A network port is the communication enpoint in a client-server model, specifying which program a communication is intended for.)

```shell
--volume or -v -> Bind mount a volume
```

Expand Down
21 changes: 13 additions & 8 deletions 08_RStudio.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ Once the image is on your local machine, you can run it with the following comma
docker run -e USER=<your-user> -e PASSWORD=<your-password> -e USERID=$UID -e GROUPID=$GID -d --rm -p 8787:8787 -v ${PWD}:/home/your-user rocker/geospatial
```
All the docker run options used here have been described in [`docker.md`](06_docker.md). Here, it is assumed that the port 8787 is not occupied on your local machine. If you do not have an instance of R studio server running, that port should be free.
The environment variables necessary to run an image with R studio server are the following:
* USER -> you can add your user name
* PASSWORD -> a secret password of your choice, along with the USER these env variables will be used to access the R studio server web interface.
* USERID and GROUPID -> these ids are needed to have the user of the host machine be the same of the docker container. When these do not match it will change the ownership of the volume you are mounting on the container, generating issues particularly when you create or save new files.

Once you have run the command you can access Rstudio server running on your local host through a browser at: [`http://localhost:8787`](http://localhost:8787) and adding your credentials.

Expand All @@ -36,24 +32,31 @@ Docker is installed on all our shared resources. Most machines already have imag
Once you accessed the server you can list the existing images with the following command:

```shell
docker images ls
docker image ls
```
You can pick the image that you need for your analysis, or pull a new image with the following command (the pull command can generally be copied from the docker hub image page, it is always good practice to check it as in some cases it needs further options):
You can pick the image that you need for your analysis, or pull a new image with the following command:

```shell
docker pull *image tag*
docker pull image-tag
```
Once you decided which image you want to use, you can start building the run command with the appropriate options:

* -d and -rm are advised, the first will automatically detach you from the container while the second will remove the container when you stop it. Do not forget to remove the container manually whether you have not added the -rm option.
* -p is needed to map the host's port with the container's port. To do this, you first need to verify which port is free to use. Ports that are permanently occupied on the servers are detailed on the servers_description file. In addition, you need to run *docker ps* to list the containers are running (if any) and verify which ports are using.
* -e with the same environment variables that have been listed above.
* -e to set the environment variables.

The final run command employing the extended image will look as follows:
```shell
docker run -e USER=<your-user> -e PASSWORD=<your-password> -e USERID=$UID -e GROUPID=$GID -d --rm -p <free-port>:8787 -v ${PWD}:/home/your-user rstudio_gdsl
```

The environment variables necessary to run an image with R studio server are the following:
* USER -> you can add your user name
* PASSWORD -> a secret password of your choice, along with the USER these env variables will be used to access the R studio server web interface.
* USERID and GROUPID -> these ids are needed to have the user of the host machine be the same of the docker container. When these do not match it will change the ownership of the volume you are mounting on the container, generating issues particularly when you create or save new files.

With the run command you generate a container where the image is running.

You can check your process with the *docker ps* command. As already mentioned above almost all rocker images include R studio server, therefore you can access the server-based application through its web interface. To do that, open your browser and go to the following address:
```shell
<host-ip>:<port>
Expand All @@ -62,3 +65,5 @@ You can find the host IP address in the document describing the servers.





4 changes: 3 additions & 1 deletion 09_Best_practices.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

Before booking a server look at the server information sheet to verify that the resource can meet your needs.

Book the Server with our booking system detailing your name, short description of tasks, forseen resources used (i.e. gpu, cpu threads,ram) - the booking system will be either an excel file or a shared calendar.
Book the Server with our booking system detailing your name, description of tasks and, when possible, forseen resources used (i.e. gpu, cpu threads,ram).

It is better to have no more than one person per server to avoid overload in the machine. However, non expensive tasks can be performed simultaneously. Always check what tasks will be performed on the booking calendar and communicate with each other.

## Docker Considerations

Expand Down

0 comments on commit 6cc1573

Please sign in to comment.