Skip to content

Commit

Permalink
Merge pull request #64 from UoMResearchIT/screenshots
Browse files Browse the repository at this point in the history
Screenshots
  • Loading branch information
fherreazcue authored Oct 24, 2024
2 parents 765bccd + 2f87e91 commit ba4eb2a
Show file tree
Hide file tree
Showing 276 changed files with 138 additions and 32 deletions.
51 changes: 25 additions & 26 deletions episodes/docker-desktop.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Therefore, **this episode is meant to be demonstrative, that is, you do not *nee
::::::::::::::::::::::::::::::::::::::: objectives
- Show Docker Desktop and its components.
- Understand what images and containers are.
- Visualize the process of image aquisition, container execution and where it ends.
- Understand the ephimeral nature of containers.
- Visualize the process of image acquisition, container execution and where it ends.
- Understand the ephemeral nature of containers.
- Have a glimpse at containers that allow interaction.
- Understand the importance of cleaning up in docker.
- Understand the limitations of Docker Desktop.
Expand All @@ -44,7 +44,7 @@ One of the useful features of Docker Desktop is the ability to search and analyz

If you open the application you will likely see something like this:

![](fig/docker-desktop/docker_desktop_landing.gif){alt='Docker Desktop being opened for the first time.'}
![](fig/docker-desktop/docker_desktop_landing.png){alt='Docker Desktop being opened for the first time.'}

You'll notice that the panel on the left has a tab for 'Images' and another for 'Containers'.
These will be the focus for the episode, and we will ignore most other features.
Expand All @@ -53,13 +53,11 @@ On the top blue bar you'll also find a search icon, which allows us to search fo

Lets go ahead and select this search box, and search for `spuacv/spuc`.

![](fig/docker-desktop/search_spuc.png){alt='Search window.'}

You may have noticed that it already shows some information about the image.
If you click on the image you'll be shown more information.
You should be able to see the documentation, and it lets you select a tag (version) from the dropdown menu.

![](fig/docker-desktop/search_select_spuc_tag.png){alt='Search and select a tag.'}
![](fig/docker-desktop/search_and_pull_spuc.gif){alt='Search and pull of SPUC container.'}

Once you find the image you were looking for, you can either download it (pull), or directly run it.

Expand All @@ -84,10 +82,10 @@ Clicking on the image will open a window with information on how the image is bu
If any of the building blocks of the image are vulnerable, we can see which, and where they come from (Image hierarchy).
For example, the vulnerabilities in the `spuc` image come from its base image, `python3-slim".

![](fig/docker-desktop/image_inspecting_spuc.png){alt='Inspecting spuc image.'}
![](fig/docker-desktop/image_inspect_spuc.gif){alt='Inspecting spuc image.'}

This all looks rather scary, and it is important that we are careful with the images that we download.
It is therefore quite useful to be able to analize them like this.
It is therefore quite useful to be able to analyse them like this.
The `python:3-slim` image, in particular, comes from a verified publisher, so it is unlikely to be malicious.

Another interesting thing to look at is the last few lines, which usually show the command that will be run when the container is started.
Expand Down Expand Up @@ -152,14 +150,14 @@ They both seem to indicate that we need to *run* or *start* the container.
Indeed, if we look carefully, we will find an 'Exited (0)' status under the container name, and a `Start` button near the top-right corner.
However, if we click on that button we will see the output duplicated in the logs, and the `Exited (0)` status again.

![](fig/docker-desktop/hello_start.png){alt='Clickling Start on the already run hello-world container.'}
![](fig/docker-desktop/hello_start.gif){alt='Clicking Start on the already run hello-world container.'}

If we go back to the images tab and run the image again, we'll see that the same thing hapens.
If we go back to the images tab and run the image again, we'll see that the same thing happens.
We get the "Hello from Docker!", and the container (with a new random name) exits.

![](fig/docker-desktop/hello_re-ran.png){alt='Running hello-world image for a second time.'}
![](fig/docker-desktop/hello_re-ran.gif){alt='Running hello-world image for a second time.'}

The nature of most containers is *ephimeral*.
The nature of most containers is *ephemeral*.

They are meant to execute a process, and when the process is completed, they exit.
We can confirm this by clicking on the `Containers` tab on the left.
Expand Down Expand Up @@ -189,7 +187,7 @@ Lets try running the `spuacv/spuc`, but look at the optional settings this time.
If you remember, we were instructed to run the container and configure a port.
Lets add a map to the port `8321` in the local machine.

![](fig/docker-desktop/run_spuc_opt.png){alt='Optional settings for spuc.'}
![](fig/docker-desktop/run_spuc_opt.gif){alt='Optional settings for spuc.'}

We are now ready to run it.
You can immediately notice the status under the container name is `Running`,
Expand Down Expand Up @@ -241,9 +239,7 @@ Lets go ahead and try that.
Open a terminal and run the command `curl -X PUT localhost:8321/unicorn_spotted?location=moon\&brightness=100`.
If you look at the logs again, you'll see that the container has responded to your command with something like:

```
{"message":"Unicorn sighting recorded!","location":"moon","brightness":100}
```
![](fig/docker-desktop/spuc_unicorn_detected.png){alt='Detecting a unicorn, spuc logs.'}

The documentation also mentioned that you can configure this print by modifying the `print.config` file.
How do we do that?
Expand All @@ -256,8 +252,6 @@ If you print the working directory with `pwd` you'll get the app's base director
You can also list the contents with `ls`, and look at the app's code.
We can even run `apt update` and install something; for example `apt install nano`.

![](fig/docker-desktop/spuc_running.gif){alt='Interacting with spuc terminal in the Exec tab.'}

As you might expect, We can also modify things, like for example the `print.config` file.
Since we have installed nano, lets use it to edit the file.
Run `nano config/print.config` and you'll see the contents of the file.
Expand All @@ -269,18 +263,22 @@ Replace the the print config line with:

Another curl now should show the changes we made to the `print.config` file.

![](fig/docker-desktop/spuc_exec.gif){alt='Interacting with spuc terminal in the Exec tab.'}

At this point, it seems like the container is very much like a virtual machine, and we can do whatever we want with it.
However, as we've mentioned before, containers are *meant to be ephimeral*.
However, as we've mentioned before, containers are *meant to be ephemeral*.

If we stop the container, we get a familiar empty tab in `Exec` and `Stats`.
The `Containers` tab on the left will also show the container status as `Exited`.

![](fig/docker-desktop/spuc_stopping.gif){alt='Stop the spuc container.'}

Lets go back to the `Images` tab, and run the `spuc` image again.
Now lets go to the `Exec` tab, and try and edit the `print.config` file again.
You'll notice that `nano` is not there anymore.
If you look at the contents of the file, for example with `cat config/print.config`, you'll see that the changes we made are gone.

![](fig/docker-desktop/spuc_second_container_run.png){alt='Exec in fresh spuc container.'}
![](fig/docker-desktop/spuc_exec_2.gif){alt='Exec in fresh spuc container.'}

When we re-ran the *image*, we created a **new** *container*.
The new container is created from the template saved in the image, and so our changes have banished.
Expand All @@ -294,6 +292,7 @@ next to the new container (which is still running, by the way).
## Reviving containers

We *can* get the old container running again, although this is rarely something we'd *want* to do.

In Docker Desktop, all we need to do is click on the `Start` button from the `Containers` list.
The terminal will appear empty, because it is a new session, but you will be able to see the changes we made before.
![](fig/docker-desktop/spuc_revival.gif){alt='Reviving container spuc.'}
Expand All @@ -307,14 +306,14 @@ However, it can also cause us problems.

Lets run the `spuc` image again, and name the container `SPUC`.

![](fig/docker-desktop/run_spuc_named.png){alt='Optional settings for spuc.'}
![](fig/docker-desktop/run_spuc_named.gif){alt='Optional settings for spuc.'}

If we look at the container list, it is much easier to find it, so the name is useful!

However, we forgot to map the port.
So lets stop this container, and launch another one.
This time we'll map the port, and use the name we wanted.
![](fig/docker-desktop/run_spuc_name_in_use_error.png){alt='Optional settings for spuc.'}
![](fig/docker-desktop/run_spuc_name_conflict.gif){alt='Optional settings for spuc.'}

This time we got an error! This is because the name `SPUC` is already "in use" by another container.
If we want the same name, we'll have to delete the old container first.
Expand All @@ -325,7 +324,7 @@ If we want the same name, we'll have to delete the old container first.
Lets go to the containers list, and delete the `SPUC` container.
There is a very convenient bin icon on the right, which will prompt you for confirmation.

![](fig/docker-desktop/spuc_delete_container.png){alt='Deleting container SPUC.'}
![](fig/docker-desktop/spuc_delete_container.gif){alt='Deleting container SPUC.'}

You should now be able to run the `spuc` image again, and name the container `SPUC`.

Expand All @@ -347,12 +346,12 @@ You may see how this can become a problem;
Particularly so because we were a bit sloppy and did not name the containers.

Let's try and get rid of the containers then.
We can conveniently select them all with the tickbox at the top, and an option to `Delete` shows up.
We can conveniently select them all with the tick-box at the top, and an option to `Delete` shows up.
Clicking on it will prompt for confirmation, and we can go ahead and accept.
![](fig/docker-desktop/delete_all_containers.gif){alt='Deleting containers.'}

All our containers are now gone. Forever. We can't get them back.
This is fine though - they were meant to be ephimeral.
This is fine though - they were meant to be ephemeral.

***Warning:*** You have to be careful here, this action deleted even the containers that were running.
You can filter the containers before you select them "all".
Expand Down Expand Up @@ -420,7 +419,7 @@ which we cannot provide from Docker Desktop.

Therefore, Docker Desktop cannot really be used for much more than being a nice dashboard.

In the next episode, we will use docker from the command line, and all of the advantages it brings will become aparent.
In the next episode, we will use docker from the command line, and all of the advantages it brings will become apparent.


:::::::::::::::::::::::::::::::::::::::: keypoints
Expand Down
12 changes: 6 additions & 6 deletions episodes/docker-hub.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ Lets go ahead and find the image we need for registering our unicorn sightings.

Open your web browser to [https://hub.docker.com](https://hub.docker.com)

![](fig/docker-hub/landing.png){alt='Dockerhub\_landing'}
![](fig/docker-hub/01_dockerhub_landing.png){alt='Dockerhub\_landing'}

In the search bar type "spuc" and hit enter.

![](fig/docker-hub/search_spuc.png){alt='Dockerhub\_search'}
![](fig/docker-hub/02_search_spuc_h.png){alt='Dockerhub\_search'}

You should see a list of images related to spuc and, amongst them, the one we were directed to.
Lets go ahead and select the [spuacv/spuc](https://hub.docker.com/r/spuacv/spuc) container image.

![](fig/docker-hub/spuc.png){alt='Dockerhub\_spuc'}
![](fig/docker-hub/03_spuc.png){alt='Dockerhub\_spuc'}

This is a fairly standard docker repository page.
The page is divided into several sections:
Expand All @@ -76,7 +76,7 @@ These versions are indicated by "tags".

If we select the "Tags" tab, we can see the list of tags for this container image.

![](fig/docker-hub/spuc_tags.png){alt='Dockerhub\_spuc\_tags'}
![](fig/docker-hub/04_spuc_tags.png){alt='Dockerhub\_spuc\_tags'}

If we click the version tag for `latest` of this image, Docker Hub shows it as `spuacv/spuc:latest`.

Expand All @@ -94,7 +94,7 @@ Tags are actually just labels, and the `latest` tag is just a convention.

You may also have noticed that there are a lot more details about the container image in the page.

![](fig/docker-hub/spuc_latest.png){alt='Dockerhub\_spuc_latest'}
![](fig/docker-hub/05_spuc_latest.png){alt='Dockerhub\_spuc_latest'}

In particular, we can see the image layers, which describe in part how the image was created.
This is a very useful feature for understanding what is in the image and evaluating its security.
Expand All @@ -118,7 +118,7 @@ Select the top result, which is the endorsed [python](https://hub.docker.com/_/p

The "official" badge is shown on the top right of the repository.

![](fig/docker-hub/python.png){alt='Dockerhub\_python'}
![](fig/docker-hub/06_python_h.png){alt='Dockerhub\_python'}

Another thing you may have noticed is that the "owner" of the image is not shown.
This is only true for official images, so instead of `OWNER/CONTAINER_IMAGE_NAME:TAG`,
Expand Down
Binary file removed episodes/fig/docker-desktop/00_lo.gif
Binary file not shown.
Binary file removed episodes/fig/docker-desktop/00_lo.png
Binary file not shown.
Binary file removed episodes/fig/docker-desktop/00_lo_h.png
Binary file not shown.
Binary file removed episodes/fig/docker-desktop/01_search.png
Binary file not shown.
Binary file removed episodes/fig/docker-desktop/02_search_name.png
Binary file not shown.
Binary file not shown.
Binary file removed episodes/fig/docker-desktop/04_pulled_3.png
Binary file not shown.
Binary file removed episodes/fig/docker-desktop/05_image_inspection.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed episodes/fig/docker-desktop/08_image_run.png
Binary file not shown.
Binary file removed episodes/fig/docker-desktop/09_image_run_prompt.png
Binary file not shown.
Binary file removed episodes/fig/docker-desktop/10_optional_settings.png
Binary file not shown.
Binary file removed episodes/fig/docker-desktop/11_hello_log.png
Binary file not shown.
Binary file removed episodes/fig/docker-desktop/12_hello_inspect.png
Binary file not shown.
Binary file removed episodes/fig/docker-desktop/13_hello_stats.png
Binary file not shown.
Binary file removed episodes/fig/docker-desktop/14_hello_terminal.png
Binary file not shown.
Binary file removed episodes/fig/docker-desktop/15_hello_start.png
Binary file not shown.
Binary file removed episodes/fig/docker-desktop/16_hello_2.png
Binary file not shown.
Binary file removed episodes/fig/docker-desktop/17_containers.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file removed episodes/fig/docker-desktop/31-32.gif
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file removed episodes/fig/docker-desktop/33-35.gif
Diff not rendered.
Binary file removed episodes/fig/docker-desktop/33_cleaning.png
Diff not rendered.
Binary file removed episodes/fig/docker-desktop/34_cleaning_2.png
Diff not rendered.
Binary file removed episodes/fig/docker-desktop/35_cleaning_3.png
Diff not rendered.
Binary file removed episodes/fig/docker-desktop/36-38.gif
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file removed episodes/fig/docker-desktop/39-42.gif
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file removed episodes/fig/docker-desktop/43_alpine.png
Diff not rendered.
Binary file removed episodes/fig/docker-desktop/44_alpine_logs.png
Diff not rendered.
Binary file removed episodes/fig/docker-desktop/45_alpine_i.png
Diff not rendered.
Binary file removed episodes/fig/docker-desktop/46_alpine_t.png
Diff not rendered.
Binary file removed episodes/fig/docker-desktop/47_alpine_s.png
Diff not rendered.
Binary file removed episodes/fig/docker-desktop/48_cowsay.png
Diff not rendered.
Binary file removed episodes/fig/docker-desktop/49_cowsay_run.png
Diff not rendered.
Binary file removed episodes/fig/docker-desktop/50_cowsay_logs.png
Diff not rendered.
Binary file removed episodes/fig/docker-desktop/51_cowsay_inspect.png
Diff not rendered.
Binary file removed episodes/fig/docker-desktop/52_cowsay_term.png
Diff not rendered.
Binary file removed episodes/fig/docker-desktop/53_cowsay_stats.png
Diff not rendered.
Binary file removed episodes/fig/docker-desktop/54_cowsay_opt.png
Diff not rendered.
Binary file added episodes/fig/docker-desktop/alpine_bind.png
Binary file added episodes/fig/docker-desktop/alpine_exec.png
Binary file added episodes/fig/docker-desktop/alpine_files.png
Binary file added episodes/fig/docker-desktop/alpine_inspect.png
Binary file added episodes/fig/docker-desktop/alpine_logs.png
Binary file added episodes/fig/docker-desktop/alpine_stats.png
58 changes: 58 additions & 0 deletions episodes/fig/docker-desktop/automation/crop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash
# Crops images in the directory from which this script is called

# To replace spaces with _ and delete parentheses from filenames:
# for file in *; do [ -f "$file" ] && mv "$file" "$(echo "$file" | tr ' ' '_' | tr -d '()')"; done

# Default crop values
DEFAULT_WIDTH=1400
DEFAULT_HEIGHT=888
DEFAULT_X=315
DEFAULT_Y=115

# Output directory
DEFAULT_OUTPUT_DIR="cropped"


# Function to display usage
usage() {
echo "Usage: $0 [-w width] [-h height] [-x x_offset] [-y y_offset]"
echo " -w width Width of the crop area (default: $DEFAULT_WIDTH)"
echo " -h height Height of the crop area (default: $DEFAULT_HEIGHT)"
echo " -x x_offset X offset of the crop area (default: $DEFAULT_X)"
echo " -y y_offset Y offset of the crop area (default: $DEFAULT_Y)"
echo " -o output_dir Output directory (default: $DEFAULT_OUTPUT_DIR)"
exit 1
}

# Parse command-line arguments
while getopts "w:h:x:y:o" opt; do
case $opt in
w) WIDTH=$OPTARG ;;
h) HEIGHT=$OPTARG ;;
x) X_OFFSET=$OPTARG ;;
y) Y_OFFSET=$OPTARG ;;
o) OUTPUT_DIR=$OPTARG ;;
*) usage ;;
esac
done

# Set default values if not provided
WIDTH=${WIDTH:-$DEFAULT_WIDTH}
HEIGHT=${HEIGHT:-$DEFAULT_HEIGHT}
X_OFFSET=${X_OFFSET:-$DEFAULT_X}
Y_OFFSET=${Y_OFFSET:-$DEFAULT_Y}
OUTPUT_DIR=${OUTPUT_DIR:-$DEFAULT_OUTPUT_DIR}

# Create output directory if it doesn't exist
mkdir -p "$OUTPUT_DIR"

# Crop all images in the current directory
for img in *.{jpg,jpeg,png,gif}; do
if [ -f "$img" ]; then
convert "$img" -crop "${WIDTH}x${HEIGHT}+${X_OFFSET}+${Y_OFFSET}" "$OUTPUT_DIR/$img"
echo "Cropped $img..."
fi
done

echo "All images have been cropped and saved to $OUTPUT_DIR"
49 changes: 49 additions & 0 deletions episodes/fig/docker-desktop/automation/gifs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

# Default delay between frames (in centiseconds, 1s = 100cs)
DEFAULT_DELAY=100

# Function to display usage
usage() {
echo "Usage: $0 [-d delay] [-i input_folder] [-o output_file]"
echo " -d delay Delay between frames in centiseconds (default: $DEFAULT_DELAY)"
echo " -i input_folder Folder containing images to create GIF from"
echo " -o output_file Output GIF file"
exit 1
}

# Parse command-line arguments
while getopts "d:i:o:" opt; do
case $opt in
d) DELAY=$OPTARG ;;
i) INPUT_FOLDER=$OPTARG ;;
o) OUTPUT_FILE=$OPTARG ;;
*) usage ;;
esac
done

# Set default values if not provided
DELAY=${DELAY:-$DEFAULT_DELAY}

# Function to create GIF from images in a folder
create_gif() {
local folder=$1
local output=$2
local delay=$3

echo "Creating GIF from images in folder '$folder' with delay $delay centiseconds..."
convert -delay $delay -loop 0 "$folder"/*.png "$output"
echo "GIF saved to '$output'"
}

# If input folder and output file are provided, create a single GIF
if [[ -n "$INPUT_FOLDER" && -n "$OUTPUT_FILE" ]]; then
create_gif "$INPUT_FOLDER" "$OUTPUT_FILE" "$DELAY"
else
# Create GIFs for each folder in the current directory
for folder in */; do
folder_name=$(basename "$folder")
output_file="${folder_name%/}.gif"
create_gif "$folder" "$output_file" "$DELAY"
done
fi
Binary file added episodes/fig/docker-desktop/containers_list.png
Binary file added episodes/fig/docker-desktop/hello_bind.png
Binary file added episodes/fig/docker-desktop/hello_exec.png
Binary file added episodes/fig/docker-desktop/hello_files.png
Binary file added episodes/fig/docker-desktop/hello_inspect.png
Binary file added episodes/fig/docker-desktop/hello_log.png
Binary file added episodes/fig/docker-desktop/hello_re-ran.gif
Binary file added episodes/fig/docker-desktop/hello_start.gif
Binary file added episodes/fig/docker-desktop/hello_stats.png
Binary file added episodes/fig/docker-desktop/image_run_hello.png
Binary file added episodes/fig/docker-desktop/image_run_prompt.png
Binary file added episodes/fig/docker-desktop/run_spuc_named.gif
Binary file added episodes/fig/docker-desktop/run_spuc_opt.gif
Binary file added episodes/fig/docker-desktop/spuc_bind.png
Binary file added episodes/fig/docker-desktop/spuc_exec.gif
Binary file added episodes/fig/docker-desktop/spuc_exec.png
Binary file added episodes/fig/docker-desktop/spuc_exec_2.gif
Binary file added episodes/fig/docker-desktop/spuc_files.png
Binary file added episodes/fig/docker-desktop/spuc_inspect.png
Binary file added episodes/fig/docker-desktop/spuc_log.png
Binary file added episodes/fig/docker-desktop/spuc_revival.gif
Binary file added episodes/fig/docker-desktop/spuc_stats.png
Binary file added episodes/fig/docker-desktop/spuc_stopping.gif
Binary file added episodes/fig/docker-hub/01_dockerhub_landing.png
Binary file added episodes/fig/docker-hub/02_search_spuc_h.png
Binary file added episodes/fig/docker-hub/03_spuc.png
Binary file added episodes/fig/docker-hub/04_spuc_tags.png
Binary file added episodes/fig/docker-hub/05_spuc_latest.png
Binary file added episodes/fig/docker-hub/06_python_h.png
Binary file removed episodes/fig/docker-hub/anaconda.gif
Diff not rendered.
Binary file removed episodes/fig/docker-hub/anaconda_01_search.png
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file removed episodes/fig/docker-hub/landing.png
Diff not rendered.
Binary file removed episodes/fig/docker-hub/matlab.gif
Diff not rendered.
Binary file removed episodes/fig/docker-hub/matlab_01_search.png
Diff not rendered.
Binary file removed episodes/fig/docker-hub/matlab_02_mathworks.png
Diff not rendered.
Diff not rendered.
Binary file removed episodes/fig/docker-hub/python.png
Diff not rendered.
Binary file removed episodes/fig/docker-hub/python_alpine318.png
Diff not rendered.
Binary file removed episodes/fig/docker-hub/search_python.png
Diff not rendered.
Binary file removed episodes/fig/docker-hub/tidyverse.gif
Diff not rendered.
Binary file removed episodes/fig/docker-hub/tidyverse_01_search.png
Diff not rendered.
Binary file removed episodes/fig/docker-hub/tidyverse_02_rocker.png
Diff not rendered.
Diff not rendered.

0 comments on commit ba4eb2a

Please sign in to comment.