Raspberry Pi is one of the most miniature computers that can allow you to build real-world applications. It is popular among developers who look to develop prototypes or IoT applications. Due to its small size and low computational power, when compared to traditional computers, Raspberry Pi has become ideal for learners as well. Users, through Raspberry Pi, can implement their code in the real-world environment and build projects. You can even deploy dockers to learn containerizations of applications in the real world.

In this article, we will briefly discuss about Raspberry Pi, Docker, and SQL Server and learn how to run MS SQL Server on Raspberry Pi using Docker. Let’s begin.

Table of Contents

  1. What is Raspberry Pi?
  2. How Raspberry Pi Works?
  3. What is Docker?
  4. How to Install Docker on Raspberry Pi?
  5. Running MS SQL Server on Raspberry Pi using Docker
  6. Conclusion

What is Raspberry Pi?

Raspberry Pi is a low-cost single-board computer, basically the size of a credit card, that can plug into a computer monitor or TV. It may be small but can do everything a desktop computer would do. Raspberry Pi is an economical-friendly computer that costs $55.00 or less, runs on Linux, and has a general purpose input and output (GPIO) protocol. It allows the user to be capable of controlling electronic components for physical computing and exploring IoT.

Raspberry Pi operates on an open source ecosystem: Linux, supported by its primary operating system: Pi OS, which runs with a suite of open source software. Raspberry Pi is mainly used to teach programming skills, build hardware projects, implement edge computing, and explore industrial applications of computer technology. Raspberry Pi is built such that it is not mandatory to have a prior knowledge of Linux or Python to work on it.

Today there is a long line of generations of Raspberry Pi, from Pi 1 to 4. These Raspberry Pi generations vary extensively in functions and usage. Raspberry Pi Zero or Raspberry Pi Zero W is the most basic model, and the latest model is the Raspberry Pi Zero 2 W.

How Raspberry Pi Works?

Raspberry Pi has a dozen of uses and applications on its own. Here are the most popular ones,

  • On a large scale, beginners buy a Raspberry Pi to learn coding, which has been one of the goals of the Raspberry Pi Foundation. 
  • People with coding knowledge use Raspberry Pi for physical projects to learn to work with electronics.
  • There are many exciting projects with the Raspberry Pi, such as a home automation system, pet cameras, and more. 

The projects and applications of Raspberry Pi are limitless if one has enough curiosity and desire.

What is Docker?

Docker Logo
Image Source

Docker is an open-source software framework for containerizing applications. Containers are the units containing all the necessary components for the software to run. This container technology offers many functions and benefits of Virtual machines (VMs), such as application isolation, cost-effective scalability, and disposability on the platform. 

Docker enables developers to bundle up applications into containers, which are capable of running in any environment because the required dependencies and libraries are available to the operating system. Using Docker makes working with containers easier, simpler, and safer. Docker can be considered a toolkit that enables developers to share, test, run, update, and deploy containers with simple commands and hassle-free automation through a single API. The Docker methodologies reduce the delayed production time between writing and running code.

Scale your data integration effortlessly with Hevo’s Fault-Tolerant No Code Data Pipeline

As the ability of businesses to collect data explodes, data teams have a crucial role in fueling data-driven decisions. Yet, they struggle to consolidate the scattered data in their warehouse to build a single source of truth. Broken pipelines, data quality issues, bugs and errors, and lack of control and visibility over the data flow make data integration a nightmare.

1000+ data teams rely on Hevo’s Data Pipeline Platform to integrate data from over 150+ sources in a matter of minutes. Billions of data events from sources as varied as SaaS apps, Databases, File Storage, and Streaming sources can be replicated in near real-time with Hevo’s fault-tolerant architecture. What’s more – Hevo puts complete control in the hands of data teams with intuitive dashboards for pipeline monitoring, auto-schema management, and custom ingestion/loading schedules. 

All of this combined with transparent pricing and 24×7 support, makes us the most loved data pipeline software on review sites.

Take our 14-day free trial to experience a better way to manage data pipelines.

Get started for Free with Hevo!

How to Install Docker on Raspberry Pi?

Docker and Raspberry Pi are both innovative technologies in the field of IT. Combining these two can help you build superior applications with a few lines of code.

There is a stepwise procedure to install Docker on Raspberry Pi, but before that, you must ensure you have a Raspberry Pi with a running Raspbian OS, Raspbian Stretch (Lit), and an enabled SSH connection.

Process to install Docker on Raspberry Pi:

Step 1: Update and upgrade your system before installing Docker.

Upgrade all the existing packages by running two commands on the Raspberry Pi terminal. 

sudo apt-get upgrade
sudo apt-get update

Step 2: Download and run the official Docker package setup script.

The official Docker package can be downloaded directly by a single bash script that installs everything for you. The command for the installation script is:

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

Then, to execute the script, use the below command:

sudo sh get-docker.sh

Step 3: Set up a non-root user for Docker.

Only root users with administrative privileges are allowed to run containers by default. Therefore, if you are not a root user, you’ll need to add the sudo prefix in all your commands. You can also add a non-root user to the Docker group, which gives access to execute the Docker commands.

Use the command below to add users to the Docker group:

sudo usermod -aG docker [user_name]

Also, you can add the default Pi user in Raspbian to the Docker group:

sudo usermod -aG docker Pi

Step 4: Verify the installation of the Docker and the Docker version.

Run the below line of code in the terminal to get the Docker version and information.

For version:

docker version

For information:

docker info

Step 5: Test run the Docker set up by running a container.

To check if the Docker is set up correctly, test by running the Hello World container. 

Type the given command below in the terminal to do so,

docker run hello-world

Running MS SQL Server on a Raspberry Pi using Docker

After installing Docker on Raspberry Pi, we can run SQL Server on Raspberry Pi. Raspberry Pi comes with an integrated ARM-compatible CPU, and the SQL server wasn’t compatible with it because SQL servers were designed only for x86 architecture. Then, Microsoft found the solution and built Azure SQL Edge on the latest SQL Server database engine version, which changed the course of working with Raspberry Pi SQL Server. 

Azure SQL Edge is built on the latest versions of the SQL Server Database Engine, designed for IoT edge deployments on Intel and ARM hardware. Azure SQL edge is an optimized relational database engine. It provides a place to stream, process, and analyze relational and non-relational data that can be developed, delivered remotely, and managed from Azure.

Azure SQL Edge provides the same Transact-SQL (T-SQL) programming surface area as SQL Server and Azure SQL, making the development of applications easier and faster. 

Azure SQL Edge is available with two different editions or software versions. 

  1. Azure SQL Edge Developer, in which each SQL edge container is limited to up to 4 cores and 32 GB memory. 
  2. Azure SQL Edge, where each SQL Edge container is limited to up to 8 cores and 64 GB memory. 

Azure SQL Edge gives two deployment options, the first is a connected deployment through Azure IoT Edge, and the second is a disconnected deployment with Docker.

Installing Azure SQL Edge on a Raspberry Pi using Docker 

To get a Raspberry Pi SQL Server, i.e., Azure SQL Edge, you need to use Docker. Docker pulls and runs the Azure SQL Edge container image and connects the container image with the Azure SQL edge command-line tool (sqlcmd), creating your first database for running queries. 

Before installing Azure SQL Edge, have a Raspberry Pi running Ubuntu and properly set up Docker.

Stepwise instructions to use Docker to deploy Azure SQL Edge:

  1. Pulling the container image.

To pull the Azure SQL Edge container image from the Microsoft container registry, write the following command in your shell:

sudo docker pull mcr.microsoft.com/azure-sql-edge:latest
  1. Run the container image.

With Docker, you’ll run the container image. 

Use the command to start an Azure SQL Edge instance,

(for developer edition)
sudo docker run --cap-add SYS_PTRACE -e 'ACCEPT_EULA=1' -e 'MSSQL_SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 --name azuresqledge -d mcr.microsoft.com/azure-sql-edge
(for premium edition)
sudo docker run --cap-add SYS_PTRACE -e 'ACCEPT_EULA=1' -e 'MSSQL_SA_PASSWORD=yourStrong(!)Password' -e 'MSSQL_PID=Premium' -p 1433:1433 --name azuresqledge -d mcr.microsoft.com/azure-sql-edge
  1. View your Docker containers by using the following command:
sudo docker ps -a
  1. Azure SQL Edge status.

If the STATUS column shows ‘Up,’ Azure SQL Edge is running in the container. And if the STATUS column shows Exited, there is some problem, look in the Azure SQL Edge Documentation Troubleshooting section in Microsoft.

  1. Change your SA password for security purposes.

Choose a strong password and Use ‘docker exec’ to run sqlcmd to change the password using T-SQL.

  1. Connecting to Azure SQL Edge

Use sqlcmd inside the container to connect to Azure SQL EdgeGive the command prompt: 

sudo docker exec -it –name “bash”

Start an interactive bash shell inside your running container.

When you get inside, connect it locally with sqlcmd. Specify the full path by using the code:

/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "<YourNewStrong@Passw0rd>"
  1. Done. On successful installation, you get a sqlcmd prompt: 1>

Conclusion

In this article, you went through the working of Docker on a Raspberry Pi for using Azure SQL Edge. We briefly discussed Raspberry Pi, Docker, and Azure SQL Edge. Mainly focused on how to run SQL Server on a Raspberry Pi. With Azure SQL Edge installed on your Raspberry Pi, you can build many IoT applications. Create and query data, play around a bit and then make your applications using machine learning and artificial intelligence.

As you collect and manage data across multiple applications and databases in your business, it is critical to consolidate it for complete business performance analysis. This is easily accomplished with a Cloud-based ETL tool like Hevo.

Visit our Website to Explore Hevo

Hevo Data will automate your data transfer process, allowing you to focus on other aspects of your business like Analytics, Customer Management, etc. Hevo provides a wide range of sources – 150+ Data Sources (including 40+ Free Sources) – that connect with over 15+ Destinations and load them into a destination to analyze real-time data at transparent pricing and make Data Replication hassle-free.

Want to take Hevo for a ride? Sign Up for a 14-day free trial and simplify your Data Integration process. Check out the Hevo Pricing details to understand which plan fulfills all your business needs.

Share your thoughts on using MS SQL on Rasberry Pi in the comments below.

Manjiri Gaikwad
Freelance Technical Content Writer, Hevo Data

Manjiri loves data science and produces insightful content on AI, ML, and data science. She applies her flair for writing for simplifying the complexities of data integration and analysis for solving problems faced by data professionals businesses in the data industry.

No-code Data Pipeline for Your Data Warehouse

Get Started with Hevo