#RaspberryPi – Manage #docker 🐳 as a non-root user

Buy Me A Coffee

Hi !

The next step for my [use Docker in a Raspberry Pi to build and deploy images] step is to configure docker as non-root user.

Lucky us, this is officially documented and easy.

Create the docker group.

sudo groupadd docker

Add your user to the docker group.

sudo usermod -aG docker $USER

Log out and log back in so that your group membership is re-evaluated.

Run a test command for docker without sudo, in example let’s see the container list

docker container ls

And that’s it!

References

Happy coding!

Greetings

El Bruno


My posts on Raspberry Pi ⚡🐲⚡

Dev posts for Raspberry Pi
Tools and Apps for Raspberry Pi
Setup the device
Hardware


¿Con ganas de ponerte al día?

En Lemoncode te ofrecemos formación online impartida por profesionales que se baten el cobre en consultoría:

#RaspberryPi – Setup SSH passwordless access to remote work with #docker 🐳

Buy Me A Coffee

Hi !

Due to some weird configurations, I’m having issues building some .NET 5 docker images locally in my Windows 10 machine. So I decided to use a Raspberry 4 as build server, and 1st step is to setup the SSH access without the need of username / password. The main resource is an official one fro the Raspberry Pi org: Passwordless SSH access.

Once we finished these steps, we can easyly configure a TCP-enabled Docker.

I followed the next steps. First, let’s edit docker.service with the command:

sudo nano /lib/systemd/system/docker.service 

And add [-H tcp://0.0.0.0:2375] at [ExecStart] section

And restart the device or just the needed services

  • run sudo systemctl daemon-reload
  • run sudo systemctl restart docker

In next posts, how to add the needed configuration to Visual Studio Code to build the images remotely in the Raspberry Pi.

Happy coding!

Greetings

El Bruno


My posts on Raspberry Pi ⚡🐲⚡

Dev posts for Raspberry Pi
Tools and Apps for Raspberry Pi
Setup the device
Hardware


¿Con ganas de ponerte al día?

En Lemoncode te ofrecemos formación online impartida por profesionales que se baten el cobre en consultoría:

#RaspberryPi – 1st setup no monitor 📺: Wifi 📶 auto connect, SSH, rename, update, docker 🐳 and more! Update 2021-Jan-29 (deprecated)

Buy Me A Coffee

Deprecated, new version available here

Hi!

Let’s start installing the latest Raspberry Pi OS image in an SD card. Next steps will be focus on how to access and control remotely your device you may want to follow this steps.

raspberry Pi Images install SO

This tutorial and tips works for Raspberry Pi 3, 4 and Zero.

Configure Wireless connection

In the SD Card, you need to create a file named [wpa_supplicant.conf] in the root of the SD card with the following information:

country=ca
update_config=1
ctrl_interface=/var/run/wpa_supplicant

network={
 scan_ssid=1
 ssid=" Your WiFi SSID"
 psk="You amazing password"
}

The file content is very straight forward to understand. Main values to complete are [ssid] and [psk].

Once you put the SD card in the device and start the device, it will automatically connect to the configured WiFi.

Enable SSH

If you also want to enable SSH, you need to create a blank file named [ssh] to the main partition.

Once you put the SD card in the device and start the device, it will automatically enable the SSH service.

So, you need to create and copy 2 files to the root of your SD card

  • wpa_supplicant.conf
  • ssh

Find the IP address in your network

And that’s it, your Raspberry Pi will be connected to the Wifi and with SSH enabled. At this moment we can use a tool like AngryIp (see references) to detect the new device in the network

My new device IP is: 192.168.1.246

I’m trying to avoid Java updates, and even install java, so lately I use a mobile app: Fing, and after a search the results are nicer.

Access via SSH

I used to like Putty to connect to my device, however during the past months I’ve been using Windows Terminal and Powershell. In order to access the device I need to execute the command

ssh user@deviceaddress

and my data is

  • user: pi
  • ip: 192.168.1.246
  • password: raspberry

You can now start working with your Raspberry Pi !

Important: the default password is raspberry, please follow next step!

Change Password

The default password for the device is “raspberry”, and as usual, it’s recommended to change it. In order to do this, in the ssh terminal, let’s access to the device configuration

sudo raspi-config

This will open the configuration for the device.

raspi config main menu

Option number 1 will allow us to change the password.

Rename the device

In the same section we can change the Host Name.

And define the new name for the Raspberry Pi device.

Expand FileSystem

Another important option in the configuration is to expand the SD disk.In the same configuration screen, select

  • 6. Advanced Options
  • Expand File System
raspi config advanced options

Now we need to reboot and after the reboot the file system should have been expanded to include all available space on your micro-SD card. Reboot with the command

sudo reboot

Update the device

There are 2 ways to update the device, using commands and using raspi-config.

  • In the Raspi Config main menu, the option 8 will launch the update commands.
  • If you prefer to manually type an update command, this one works for me
sudo -- sh -c 'apt-get update; apt-get upgrade -y; apt-get dist-upgrade -y; apt-get autoremove -y; apt-get autoclean -y'
updates complete

Install Docker

The information is available from the Official Docker Documentation

curl -fsSL https://get.docker.com -o get-docker.sh

sudo sh get-docker.sh

And then, a simple check for the docker version with the command

docker version

Conclusion

And that’s it, we have our device updated and running with the latest software versions and we didn’t use a monitor! I’ll update this post frequently to make it relevant with my personal best practices.

Happy coding!

Greetings

El Bruno


My posts on Raspberry Pi ⚡🐲⚡

Dev posts for Raspberry Pi
Tools and Apps for Raspberry Pi
Setup the device
Hardware

#RaspberryPi – Install #AzureIoT, a couple of tips to make it work

Buy Me A Coffee

Hi !

I’m back to Azure IoT for some months, so while I’m refreshing a couple of devices I realized that I need to write some lessons learned here.

The base steps for this posts are described in the official page [Install or uninstall Azure IoT Edge for Linux] (see references). In the official documentation, you can also find the prerequisites and links on additional steps. I’ll start here when you already have an Azure IoT environment, a connection string for an Edge Device and a Raspberry Pi 4 with Raspberry Pi OS installed. Let’s go.

Let’s prepare your device to access the Microsoft installation packages.

curl https://packages.microsoft.com/config/debian/stretch/multiarch/prod.list > ./microsoft-prod.list

Copy the generated list to the sources.list.d directory.

sudo cp ./microsoft-prod.list /etc/apt/sources.list.d/

Install the Microsoft GPG public key.

curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo cp ./microsoft.gpg /etc/apt/trusted.gpg.d/

Now that we added the Microsoft sources, it’s time to update our package lists

sudo apt-get update

[Bruno] I also did a full update

sudo -- sh -c 'apt-get update; apt-get upgrade -y; apt-get dist-upgrade -y; apt-get autoremove -y; apt-get autoclean -y'

[Bruno] and before install the docker engine (moby-engine), I installed this specific version of libssl

sudo apt-get install libssl1.0.2

Install the Moby engine.

sudo apt-get install moby-engine

Time to update again the packages

sudo apt-get update

And time to install the most recent version of IoT Edge

sudo apt-get install iotedge

From here and on, you can check the official documentation on how to add your device connection string to register the device. Once the device is registered the following command will help us to check the service

sudo systemctl status iotedge

An output similar to this one is a great OK message !

azure Iot working fine

Happy coding!

Greetings

El Bruno


References

My posts on Raspberry Pi ⚡🐲⚡

Dev posts for Raspberry Pi
Tools and Apps for Raspberry Pi
Setup the device
Hardware


¿Con ganas de ponerte al día?

En Lemoncode te ofrecemos formación online impartida por profesionales que se baten el cobre en consultoría:

#RaspberryPi – Fing >> mobile app 📲 to detect your device IP 📶. Update on old way to detect this IP address

Buy Me A Coffee

Hi !

I just updated my “1st setup without monitor: auto connect to WiFi, enable SSH, rename, update and more!” post, on the section about how to detect your Raspberry Pi IP address once connected to the network. I used a Java based program, and I want to avoid install Java as long as I can.

To get the IP I will use a mobile app: Fing (see references). And it just need 2 steps

  1. Connect to the same network and start scanning

2. Review the list of detected devices and look for the one named: Raspberry

By default, the brand is Raspberry Pi and the default name is Raspberry, so it makes sense to try this IP addresses first.

Happy coding!

Greetings

El Bruno


References


¿Con ganas de ponerte al día?

En Lemoncode te ofrecemos formación online impartida por profesionales que se baten el cobre en consultoría:

#RaspberryPi – 1st setup no monitor: Wifi auto connect, SSH, rename, update, docker and more! Update 2020-Dec-21 (deprecated)

Buy Me A Coffee

Deprecated, new version available here

Hi!

Let’s start installing the latest Raspberry Pi OS image in an SD card. Next steps will be focus on how to access and control remotely your device you may want to follow this steps.

raspberry Pi Images install SO

This tutorial and tips works for Raspberry Pi 3, 4 and Zero.

Configure Wireless connection

In the SD Card, you need to create a file named [wpa_supplicant.conf] in the root of the SD card with the following information:

country=ca
update_config=1
ctrl_interface=/var/run/wpa_supplicant

network={
 scan_ssid=1
 ssid=" Your WiFi SSID"
 psk="You amazing password"
}

The file content is very straight forward to understand. Main values to complete are [ssid] and [psk].

Once you put the SD card in the device and start the device, it will automatically connect to the configured WiFi.

Enable SSH

If you also want to enable SSH, you need to create a blank file named [ssh] to the main partition.

Once you put the SD card in the device and start the device, it will automatically enable the SSH service.

So, you need to create and copy 2 files to the root of your SD card

  • wpa_supplicant.conf
  • ssh

Find the IP address in your network

And that’s it, your Raspberry Pi will be connected to the Wifi and with SSH enabled. At this moment we can use a tool like AngryIp (see references) to detect the new device in the network

My new device IP is: 192.168.1.246

Access via SSH

I used to like Putty to connect to my device, however during the past months I’ve been using Windows Terminal and Powershell. In order to access the device I need to execute the command

ssh user@deviceaddress

and my data is

  • user: pi
  • ip: 192.168.1.246
  • password: raspberry

You can now start working with your Raspberry Pi !

Important: the default password is raspberry, please follow next step!

Change Password

The default password for the device is “raspberry”, and as usual, it’s recommended to change it. In order to do this, in the ssh terminal, let’s access to the device configuration

sudo raspi-config

This will open the configuration for the device.

raspi config main menu

Option number 1 will allow us to change the password.

Rename the device

In the same section we can change the Host Name.

And define the new name for the Raspberry Pi device.

Expand FileSystem

Another important option in the configuration is to expand the SD disk.In the same configuration screen, select

  • 6. Advanced Options
  • Expand File System
raspi config advanced options

Now we need to reboot and after the reboot the file system should have been expanded to include all available space on your micro-SD card. Reboot with the command

sudo reboot

Update the device

There are 2 ways to update the device, using commands and using raspi-config.

  • In the Raspi Config main menu, the option 8 will launch the update commands.
  • If you prefer to manually type an update command, this one works for me
sudo -- sh -c 'apt-get update; apt-get upgrade -y; apt-get dist-upgrade -y; apt-get autoremove -y; apt-get autoclean -y'
updates complete

Install Docker

The information is available from the Official Docker Documentation

curl -fsSL https://get.docker.com -o get-docker.sh

sudo sh get-docker.sh

And then, a simple check for the docker version with the command

docker version

Conclusion

And that’s it, we have our device updated and running with the latest software versions and we didn’t use a monitor! I’ll update this post frequently to make it relevant with my personal best practices.

Happy coding!

Greetings

El Bruno


My posts on Raspberry Pi ⚡🐲⚡

Dev posts for Raspberry Pi
Tools and Apps for Raspberry Pi
Setup the device
Hardware

#Coding4Fun – RaspberryPi LED Christmas Tree 🎄 sync with Microsoft Teams (2/N) Azure AD, 🦒 and Apps

Buy Me A Coffee

Hi !

Back in the Microsoft Lync days, we had access to an SDK that allowed us to interact with the Messaging client in a local mode. As of today, there is not similar SDK to interact with Microsoft Teams. So, if I want to know the status of an user in Microsoft Teams, we need to call the Microsoft Graph. And this is not as simple as 2 lines in Microsoft Lync SDK.

Note: I’m fully supporting the Microsoft Graph 👇👇👇

Bruno and Nilesh Graph

Using the Graph is super easy. I mean, once you understand the entities and elements, is easy to make queries to get Graph information. The tricky part is to get permissions to call the Graph.

Isacc describes the process very well in the [Configuring an Azure Active Directory Application] section of his blog (see references). There are 2 main steps here

  • Create and add an application to an Azure AD
  • Grant permissions to the new App

Avanade is not as big as Microsoft, however just try to get permissions to create an App into our Azure AD to lab and test, is a colossal task. Tons of internal approvals, security checks, etc. Is not as easy as use a local SDK. That’s a boomer.

We have a Virtual Innovation Center to present and lab ideas, and I have full control there. So, I’m using this environment for labs, while I’m figuring out the best way to trigger this in Avanade.

Again, I need to learn more about this. The latest version of Presence Light does not longer requires Admin Consent, so this is no longer an issue for folks that want to get Presence. It didn’t work for me so, I created the app, and is up and running !

Again, please read Isaac post. He really explains the full process for this.

Raspberry Pi Christmas

Happy coding!

Greetings

El Bruno


References

#Coding4Fun – #RaspberryPi LED Christmas Tree 🎄 sync with #MicrosoftTeams (1/N) Why? Why not !

Buy Me A Coffee

Hi !

So I was preparing boxes with gadgets I have for our next house move, and I realized that I had a super cool Led based Christmas Tree, that can be used with a Raspberry Pi. The device can be programmed with Python, so I decided to go in my notes and I found something different to test the tree:

Sync the Tree Lights with my Microsoft Teams Status

Something like this !

After Build 2020, I have some notes from Scott Hanselman and Isaac Levin, which explains a way to start with this, please see references.

Note: Isaac Presence Light app does 90% of the work, kudos to him here!

So, I decided to start easy and create a simple Python Flask WebApp with the following end points

  • setcolor (color as parameter)
  • off
  • on
  • away
  • online
  • busy

Microsoft Teams supports much more states, but this ones are good enough for me to test the app.

The app is super simple, here goes the code

# Bruno Capuano
# simple webserver with flask
# change raspberry pi tree colours

from flask import Flask, request                                                
from tree import RGBXmasTree
from time import sleep
from colorzero import Color

def set_tree_color(new_color):
    global tree
    print(f'set color: {new_color}')
    tree.color = Color(new_color)
    return new_color

app = Flask(__name__)
tree = RGBXmasTree()

@app.route("/setcolor")
def set_color():
    # http://rpi8gb:8090/setcolor?color=red
    color = request.args.get("color")
    return set_tree_color(color)    

# Microsoft Team Status

@app.route("/off")
def set_off():
    global tree
    tree.off()
    return 'OK'

@app.route("/on")
def set_on():
    global tree
    tree.on()
    return 'OK'    

@app.route("/away")
def teams_away():
    return set_tree_color('yellow')

@app.route("/online")
def teams_online():
    return set_tree_color('green')

@app.route("/busy")
def teams_busy():
    return set_tree_color('red')

if __name__ == '__main__':
    # Run the server
    app.run(host='0.0.0.0', port=8090)

And, time for settings and config in the Presence Light App (next post more details about this). My device name is RPI8GB, so you can understand the Custom API Uris.

Presence Light config for Raspberry Pi Christmas Tree

And it was running !

More details and a better experience in future posts.

Happy coding!

Greetings

El Bruno


References

#RaspberryPi – New OS allows #MicrosoftTeams in the device ! And a simple but amazing config for the onboard LED

Buy Me A Coffee

Hi !

We have a new Raspberry Pi OS release – December 2020 (see references) and it adds tons of new features. The latest version upgrades Chromium, to a version that allow us to to: join teams calls !

2020-12-07 Teams on Raspberry Pi

I’m starting to think on have a custom Teams Kiosk just to join meetings, without using my computer. I’ll write more about this later.

Back to the new features, one of them is super interesting: Power LED

Quoting the original post

On the System tab, if you are running on Raspberry Pi with a single status LED (i.e. a Raspberry Pi Zero or the new Raspberry Pi 400), there is now an option to select whether the LED just shows that the power is on, or if it flickers off to show drive activity.
LED control in Raspberry Pi Configuration

This is great ! Somehow, have the led blinking means that the device is working, and in some scenarios, for is great to look at my +10 devices and visually knows if they are all working fine.

Disclaimer: I know I need to get an extra RPi and create a dashboard with the status of the +10 devices. That’s the cool tech solution. However, stacked devices and led are simple and amazing.

Important: as of today, some of the new changes are not available in the x64 OS versions. They are adding new features to the x64 OS image, so it will include these changes later.

Happy coding!

Greetings

El Bruno


Resources

#RaspberryPi – Raspberry Pi 400,

Buy Me A Coffee

Hi !

It seems that it was yesterday when I wrote about the amazing and new Raspberry Pi 4, and it was on February ! There was a lot of news since February, however the Raspberry 400 is a huge milestone.

From a hardware view, is a faster device, that’s cool. However I really like the all-in-one format:

Raspberry Pi 400, a compact keyboard with an ARM-based computer built in.

Start is super easy

  • Add your SD card with your OS image
  • Connect 1 or 2 monitors using the 2 micro HDMI ports
  • Power the device
  • Optional, connect a mouse
  • that’s all !

The specs are super cool:

  • Broadcom BCM2711 quad-core Cortex-A72 (ARM v8) 64-bit SoC @ 1.8GHz
  • 4GB LPDDR4-3200
  • Dual-band (2.4GHz and 5.0GHz) IEEE 802.11b/g/n/ac wireless LAN
  • Bluetooth 5.0, BLE
  • Gigabit Ethernet
  • 2 × USB 3.0 and 1 × USB 2.0 ports
  • Horizontal 40-pin GPIO header
  • 2 × micro HDMI ports (supports up to 4Kp60)
  • H.265 (4Kp60 decode); H.264 (1080p60 decode, 1080p30 encode); OpenGL ES 3.0 graphics
  • MicroSD card slot for operating system and data storage
  • 78- or 79-key compact keyboard (depending on regional variant)
  • 5V DC via USB connector
  • Operating temperature: 0°C to +50°C ambient
  • Maximum dimensions 286 mm × 122 mm × 23 mm

I am really looking forward to test the GPIO pins on the back of the keyboard. I have several hats, and connectors for this, so I’m sure that we will see some adapters in the near future:

And I really like this analogy from FastCompany (see references)

Of course, the computer-in-a-keyboard concept isn’t new. As The Verge notes, the Raspberry Pi 400 is a throwback of sorts to classic PCs like the BBC Micro, ZX Spectrum, or Apple IIe, and some vendors such as Asus have tried to revive the concept before. But with Raspberry Pi’s low pricing and its emphasis on education, now might be just the right time for a revival. The only question is when Raspberry Pi takes the next logical step and makes a full-blown laptop.

Happy coding!

Greetings

El Bruno


References

My posts on Raspberry Pi ⚡🐲⚡

Dev posts for Raspberry Pi
Tools and Apps for Raspberry Pi
Setup the device
Hardware