Next up in my quest to learn more about running containers on a Raspberry Pi, was to test a container that I created a while ago when I was ramping up on Flask and Python. I created a basic container that generates a list of 8 random exercises (from a pool of 26), I was in the process of putting together a new workout regime at the time, so this seemed like a perfect way to build something that had practical use in my life.
The first thing I needed to do was download the repo to my Raspberry Pi, to do this I ran the following command (from within the directory I wanted to temporarily store the downloaded repo).
git clone https://github.com/brendankarl/Containers
Once I had the repo downloaded locally on my Pi, I needed to change into the directory that housed the specific container I was interested in (WorkoutGenerator) as the repo has others.
I then needed to create the image using Docker Build, the command below references the Dockerfile within the repo and names the image “workoutgenerator”.
docker build -t workoutgenerator ./
Once this command complete, I could then run the image, exposing port 80 on the container to the Raspberry Pi so that I could access it from within my network. If you are interested in exposing things externally ngrok is a great free tool I’d recommend taking a look at.
docker run -d -p 80:80 workoutgenerator
A quick peek into Docker using the Visual Studio Code extension and I could see the container running and the images added to support this.
Finally, I launched a browser and hit the IP address of the Raspberry Pi to check that everything was running correctly – voila it was working!
I refreshed the page a couple of times to verify that the exercises were updated.
That’s enough containers for me today…..I need a workout 😂.