🕹 Challenges & Exploration
You as a student need to fill in these assignments and learning goals by yourself. At the start of each next chapter the lecturer will, together with class, review these in an overall sense but will not give the full, word-by-word, solution for you to simply sit back and download. So it is important that you have completed the work yourself before the review starts in class and you can correct where needed.
You are not allowed to use AI like ChatGPT or Bing Copilot on the exam, but you are here! Leverage these new tools to speed up and give structure to your notes and documents. For example, ask to put material in Markdown format!
📝 After completing these challenges, you need to be able to:
Docker environment variables:
- Define and explain what environment variables are and how they are used in Docker containers.
- List the benefits of using environment variables in Docker containers.
- Give examples of common environment variables for different Docker containers like database related variables and how to set them in the command line.
- Describe what Grafana is and how it can be used to visualize and monitor data from various sources.
Docker volumes:
- Explain what Docker volumes and bind mounts are and what they are used for.
- List the advantages of using Docker volumes.
- Give examples of common commands and options to create, list, inspect, remove, and prune volumes, and to start a container with a volume.
- List the steps to run a MySQL container using environment variables and a volume to store the data.
🛠 Configuring your containers - Docker Environment variables
Look up what environment variables are when talking about Docker containers, looking at this article and this article page. Also look up what the benefits are of using environment variables in Docker containers.
Now let's run some containers that use these enviroment variables.
🗃 NoSQL MongoDB container
Start up a MongoDB container (official image page) and make sure that you use environment variables in the command to:
- Set the root username
- Set the root password
Then try to insert this item in the database, via MongoDB Compass or the mongosh
commandline on your laptop (install either if needed):
{
"productcode": "XRP55048S",
"name": "Normal Portland Cement Plastic Bag 25Kg",
"type": "Construction goods",
"price": 29.99
}
Then make a Python script, or adjust the previous one you had, to read this item from the database.
📊 Grafana container
Grafana is an open source tool that lets you create and manage dashboards, alerts, reports and more for your data.
Investigate what Grafana is and list its main features and uses.
Start up a Grafana container (official image page) and make sure that you use environment variables in the command to:
- Set the admin password
- Install the Clock Panel Plugin for Grafana plugin
- Install the Infinity plugin
If needed you can also use docker exec
and grafana cli after having created the container to install the plugins.
After that login to the Grafana instance create a dashboard with a clock panel from the Clock Panel Plugin as a try-out.

If you want to know more about Grafana you can take a look at this guide.
🛠 Being persistent about it - Docker volumes & bind mounts
Deploying these database containers might have had you thinking: What happens with the data? It of course gets deleted together with the container as it is simply located within it.
This is not a problem anymore when you use Docker Volumes.
Start from this article (disregard the Dockerfile and Docker Compose parts for now) & this this article. And look up what:
- Docker Volumes are, and specifically named volumes.
- Bind mounts (also called host volumes) are.
- Why each could be useful.
🗃 MySQL - revisted
Start up a MySQL container (official image page) and make sure that you use environment variables in the command to:
- Set the root password
Then also create a volume in the command to make sure that the data get written to that volume instead of keeping it in a container. The type of volume you will be using here is called a named volume.
When you have started the container, insert some data and then delete the container again. Look for the volumes in the Docker Desktop GUI app. Is it still there?
Now re-run your command to create a MySQL container again. Does the volume re-attach and can you read that data in it again with MySQL?
After this also delete the volume seperately with a Docker command.
🎮 Old school gaming - an OpenTTD game server container
OpenTTD is an open-source simulation game based on Transport Tycoon Deluxe. It involves building and managing a transportation network.

Start up an OpenTTD server container (image page) on both TCP and UDP ports and make sure that you use environment variables in the command to:
- Make it try to load autosave/exit.sav, otherwise default to a new game
Then create two volumes in the command as well:
- a volume that mounts a local folder on your computer to that volume for the config
.cfg
- a volume that mounts a local folder on your computer to that volume for the save file
Both of these volumes are also bind mounts/host volumes.
Download the Zip-archive version of the OpenTDD game client and try to connect to your server via the Network game -> LAN games menu.