Return to site

Docker And Raspberry Pi

broken image


Sponsored By

Earlier this week I set up .NET Core and Docker on a Raspberry Pi and found that I could run my podcast website quite easily on a Pi. Check that post out as there's a lot going on. I can test within a Linux Container and output the test results to the host and then open them in VS. I also explored a reasonably complex Dockerfile that is both multiarch and multistage. I can reliably build and test my website either inside a container or on the bare metal of Windows or Linux. Very fun.

As primarily a Windows developer I have lots of batch/cmd files like 'test.bat' or 'dockerbuild.bat.' They start as little throwaway bits of automation but as the project grows inevitably more complex.

The Raspberry Pi is an excellent platform for starting to learn OpenCV and also doubles as an affordable and small device. Here is all the equipment that we recommend for this Raspberry Pi OpenCV tutorial. Raspberry Pi 1, 2, 3 or 4. Ethernet Cord or WiFi dongle (The Pi 3 and 4 has WiFi.

I'm not interested in 'selling' anyone PowerShell. If you like bash, use bash, it's lovely, as are shell scripts. PowerShell is object-oriented in its pipeline, moving lists of real objects as standard output. They are different and most importantly, they can live together. Just like you might call Python scripts from bash, you can call PowerShell scripts from bash, or vice versa. Another tool in our toolkits.

Docker And Raspberry Pi Emulator

  1. Earlier this week I set up.NET Core and Docker on a Raspberry Pi and found that I could run my podcast website quite easily on a Pi. Check that post out as there's a lot going on. I can test within a Linux Container and output the test results to the host and then open them in VS.
  2. The Raspberry Pi is a popular single-board computer designed to promote the teaching of computer science in schools. The use of the Raspberry Pi computer ranges from robotics to home automation. Many variations of the Raspberry Pi exist, such as the Raspberry Pi Zero, which is smaller than the more powerful Raspberry Pi 4.
  3. The database that is being used in the docker-compose file on the site isn't compatible with ARM processors, so we'll need to change that in a bit. But first, we need to get logged in to our Raspberry Pi's Portainer. This tutorial assumes that you already have Docker and Portainer installed, most likely via OpenMediaVault.
  4. Learn how to install Portainer to your Raspberry Pi. Portainer is a Docker management tool that makes managing your containers a breeze. Creating and maintaining your Docker containers becomes a simple task when using this web interface.
Raspberry
Docker and raspberry pi

Bash and shell scripts are SUPER powerful. It's a whole world. But it is text based (or json for some newer things) so you're often thinking about text more.

You can take it as far as you like. For some it's intuitive power, for others, it's baroque.

Point is, there's choice. Here's a nice article about PowerShell from the perspective of a Linux user. Can I install PowerShell on my Raspberry Pi (or any Linux machine) and use the same scripts in both places? YES.

For many years PowerShell was a Windows-only thing that was part of the closed Windows ecosystem. In fact, here's video of me nearly 12 years ago (I was working in banking) talking to Jeffrey Snover about PowerShell. Today, PowerShell is open source up at https://github.com/PowerShell with lots of docs and scripts, also open source. PowerShell is supported on Windows, Mac, and a half-dozen Linuxes. Sound familiar? That's because it's powered (ahem) by open source cross platform .NET Core. You can get PowerShell Core 6.0 here on any platform.

Don't want to install it? Start it up in Docker in seconds with

Sweet. How about Raspbian on my ARMv7 based Raspberry Pi? I was running Raspbian Jessie and PowerShell is supported on Raspbian Stretch (newer) so I upgraded from Jesse to Stretch (and tidied up and did the firmware while I'm at it) with:

The docker documentation says that if you still have problems, you should add the certificate at the OS level. I have done so according to the instructions: Docker Documentation – 6 Jan 18. Docker add certificate to truststore. I am running an ASP.NET Core 1.1 Web API in a Docker 1.13.1 container on Ubuntu 14.04. When the code attempts to retrieve some data from an HTTPS server, I get this certificate authentication erro. Restart Docker for the changes to take effect. Open Windows Explorer, right-click the certificate, and choose Install certificate. Then, select the following options: Store location: local machine; Check place all certificates in the following store; Click Browser, and select Trusted Root Certificate Authorities; Click Finish. You may need to restart the docker service to get it to detect the change in OS certificates. Docker does have an additional location you can use to trust individual registry server CA. Storage customization Customize the storage location. By default, your registry data is persisted as a docker volume on the host filesystem. If you want to store your registry contents at a specific location on your host filesystem, such as if you have an SSD or SAN mounted into a particular directory, you might decide to use a bind mount instead.

Cool. Now I'm on Raspbian Stretch on my Raspberry Pi 3. Let's install PowerShell! These are just the most basic Getting Started instructions. Check out GitHub for advanced and detailed info if you have issues with prerequisites or paths.

NOTE: Here I'm getting PowerShell Core 6.0.2. Be sure to check the releases page for newer releases if you're reading this in the future. I've also used 6.1.0 (in preview) with success. The next 6.1 preview will upgrade to .NET Core 2.1. If you're just evaluating, get the latest preview as it'll have the most recent bug fixes.

Lovely.

GOTCHA: Because I upgraded from Jessie to Stretch, I ran into a bug where libssl1.0.0 is getting loaded over libssl1.0.2. This is a complex native issue with interaction between PowerShell and .NET Core 2.0 that's being fixed. Only upgraded machines like mind will it it, but it's easily fixed with sudo apt-get remove libssl1.0.0

Docker And Raspberry Pi
Docker and raspberry pi

Bash and shell scripts are SUPER powerful. It's a whole world. But it is text based (or json for some newer things) so you're often thinking about text more.

You can take it as far as you like. For some it's intuitive power, for others, it's baroque.

Point is, there's choice. Here's a nice article about PowerShell from the perspective of a Linux user. Can I install PowerShell on my Raspberry Pi (or any Linux machine) and use the same scripts in both places? YES.

For many years PowerShell was a Windows-only thing that was part of the closed Windows ecosystem. In fact, here's video of me nearly 12 years ago (I was working in banking) talking to Jeffrey Snover about PowerShell. Today, PowerShell is open source up at https://github.com/PowerShell with lots of docs and scripts, also open source. PowerShell is supported on Windows, Mac, and a half-dozen Linuxes. Sound familiar? That's because it's powered (ahem) by open source cross platform .NET Core. You can get PowerShell Core 6.0 here on any platform.

Don't want to install it? Start it up in Docker in seconds with

Sweet. How about Raspbian on my ARMv7 based Raspberry Pi? I was running Raspbian Jessie and PowerShell is supported on Raspbian Stretch (newer) so I upgraded from Jesse to Stretch (and tidied up and did the firmware while I'm at it) with:

The docker documentation says that if you still have problems, you should add the certificate at the OS level. I have done so according to the instructions: Docker Documentation – 6 Jan 18. Docker add certificate to truststore. I am running an ASP.NET Core 1.1 Web API in a Docker 1.13.1 container on Ubuntu 14.04. When the code attempts to retrieve some data from an HTTPS server, I get this certificate authentication erro. Restart Docker for the changes to take effect. Open Windows Explorer, right-click the certificate, and choose Install certificate. Then, select the following options: Store location: local machine; Check place all certificates in the following store; Click Browser, and select Trusted Root Certificate Authorities; Click Finish. You may need to restart the docker service to get it to detect the change in OS certificates. Docker does have an additional location you can use to trust individual registry server CA. Storage customization Customize the storage location. By default, your registry data is persisted as a docker volume on the host filesystem. If you want to store your registry contents at a specific location on your host filesystem, such as if you have an SSD or SAN mounted into a particular directory, you might decide to use a bind mount instead.

Cool. Now I'm on Raspbian Stretch on my Raspberry Pi 3. Let's install PowerShell! These are just the most basic Getting Started instructions. Check out GitHub for advanced and detailed info if you have issues with prerequisites or paths.

NOTE: Here I'm getting PowerShell Core 6.0.2. Be sure to check the releases page for newer releases if you're reading this in the future. I've also used 6.1.0 (in preview) with success. The next 6.1 preview will upgrade to .NET Core 2.1. If you're just evaluating, get the latest preview as it'll have the most recent bug fixes.

Lovely.

GOTCHA: Because I upgraded from Jessie to Stretch, I ran into a bug where libssl1.0.0 is getting loaded over libssl1.0.2. This is a complex native issue with interaction between PowerShell and .NET Core 2.0 that's being fixed. Only upgraded machines like mind will it it, but it's easily fixed with sudo apt-get remove libssl1.0.0

Now this means my PowerShell build scripts can work on both Windows and Linux. This is a deeply trivial example (just one line) but note the 'shebang' at the top that lets Linux know what a *.ps1 file is for. That means I can keep using bash/zsh/fish on Raspbian, but still 'build.ps1' or 'test.ps1' on any platform.

Here's a few totally random but lovely PowerShell examples: Mac games free. download full version.

You can take PowerShell objects to and from Objects, Hashtables, JSON, etc.

Docker And Raspberry Pi Ssh

Here's a nice one from MCPMag:

Or a one-liner if you want to be obnoxious.

Docker And Raspberry Pi Raspberry Pi

Example: This won't work on Linux as it's using Windows specific AIPs, but if you've got PowerShell on your Windows machine, try out this one-liner for a cool demo:

iex (New-Object Net.WebClient).DownloadString('http://bit.ly/e0Mw9w')

Thoughts?

Sponsor: Check out JetBrains Rider: a cross-platform .NET IDE. Edit, refactor, test and debug ASP.NET, .NET Framework, .NET Core, Xamarin or Unity applications. Learn more and download a 30-day trial!

Docker And Raspberry Pie

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

Docker Raspberry Pi 2


Docker Raspberry Pi Zero

AboutNewsletter



broken image