Brian Veltman

Tech, food & my silly life

Part 1: Raspberry Pi 3 B+ and Docker

We’re going to start from scratch. If you find this a bit too daunting you can get yourself a Raspberry Pi with most commonly used software preinstalled.

What to expect of this chapter

It’s a small chapter with small and easy steps.
We’re going to prepare our Raspberry Pi 3 B+ to act as our smart home hub. Therefore we have to get a Raspberry Pi with a Micro SD card of at least 4GB. However, I do recommend to get a 32GB card so you do not run out of space during these series.

Back in the day we tend to install software on the Operating System directly. Like you may have been doing for years.
Couple of years ago a new technology popped up named Docker. Docker allows us to install software in isolated ‘containers’. The benefit of this approach; we do not have to clutter or change the Operating System. If things go wrong, it will not affect other software. When things go wrong, we simply remove the container with the faulty software and we start over again.

Preparing Raspberry Pi 3 B+

Assuming you have a Raspberry Pi by now, let’s assemble it.
My RaspBerry Pi 3 B+ got delivered with a power supply, hard plastic shell/cover and 3 heatsinks.
Usually, the Raspberry does not need any of these heatsinks, unless you are planning to use it as a video streaming or media server.

Anyway, let’s apply 2 heatsinks, it will not damage the device. When unpacking the Raspberry make sure you hold it on the sides. Do not touch the flat surfaces, it may damage the components on the board due to our static charge.

Another thing to mention when applying the heatsinks; do not apply the heatsink on the memory. If you do so your cover/shell will not fit.
My Pi looks like this after applying 2 heatsinks and cover.

Preparing the Micro SD card

Before we can install the Micro SD card into the Raspberry Pi 3 B+ we do have to wipe it.
For this, I’m using SD Card Formatter which can be downloaded for free at https://www.sdcard.org/downloads/formatter_4/index.html.

Once installed, insert your Micro SD card into your computer and open up SD Card Formatter. If you do not have any other SD cards inserted, the app will recognize your Micro SD card automatically. You can choose for a quick format if it’s a brand new Micro SD card. Otherwise, I recommend doing an overwrite.
Formatting can take up to 45-60min if you do an overwrite. If you do a quick format it will be finished within a minute.

Now we have a completely wiped SD card, it’s time to flash the card. Flashing, in this case, means we’re going to install a copy of the Raspbian Operating System on it. Raspbian is a version of Linux’s popular Debian operating system designed for Raspberry Pi.

We’re taking the easy route here. Let’s download Etcher and a copy of Raspbian Stretch Lite.

https://downloads.raspberrypi.org/raspbian_lite_latest
https://www.balena.io/etcher/

Once downloaded both, Raspbian and Etcher, open up the Raspbian .zip archive and unzip it to your desktop.
Open up the Etcher application and select your unzipped Raspbian.img file from your desktop.
The next step is to select your SD card followed by “Flash”. This process can take up 10-15 minutes. Get yourself a drink.

Before we insert the SD card into the Raspberry Pi 3 B+, we have to make sure we can access the device remotely from another computer.
Therefore we have to set up SSH access.
Open up your Terminal of choice. I’m using MacOS’s native Terminal application.

Type the following commands in your terminal:

cd /Volumes/boot && touch ssh

That’s it! the hard part of this chapter has been done.

Putting it together

Now we can eject the SD card from your computer and insert it into the Raspberry Pi 3 B+.
On the back of the Raspberry Pi 3 B+ is a little slot. Insert your Micro SD card in this slot.

Once you’re done you can connect the power adapter, UTP Ethernet cable and wait for a minute or two for the Raspberry Pi to start.
Just for sake of the argument, make sure the other end of your UTP Ethernet cable is plugged in into your router.

Get the IP address and connect!

These are our last few steps to make Raspberry Pi 3 B+ working. Figuring out the IP address of our Pi so we can connect to it using SSH.

If you do have access to your router admin page, http://192.168.1.254 for example, you can lookup the IP fairly easy.
Unfortunately I can not guide you through this process since there are many routers and interfaces which all work differently.

I was able to find the local IP of the Pi in my Netgear Orbi router.

Now we know the IP of the Pi we can connect to it by using the Terminal and enter this command:

ssh pi@192.168.1.13

The first time you connect it ask you if the fingerprint matches. Just type ‘yes’.
Now you will be asked for the password. By default, this is ‘raspberry’.
Note: when you type the password nothing will show up for security reasons.
Hit enter after you have typed the password, viola! we’re in.

You have successfully installed Raspberry Pi 3 B+

Install Docker

We’re reaching the end of this first chapter in the IoT series.
Installing Docker is a breeze. We’re already logged in into the Raspberry Pi.
Now it’s time to run the following command:

curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh

This will take a minute or 5, after that we can run:

sudo usermod -aG docker pi && sudo reboot

Login back to your Pi, now we can use the docker commands without using ‘sudo‘.

Things we have not covered in this chapter, but which I do encourge you to find out on yourself are the following topics:

  • Assignning a fixed IP address to your Raspberry Pi
  • Learn the concepts of Docker
  • Learn the basic Linux commands

That’s it for now! enjoy your Pi, and if you screw up, feel free to start from scratch 😉

1 thought on “Part 1: Raspberry Pi 3 B+ and Docker

Comments are closed.

Scroll Up