How to Install Docker on Raspbian OS

29/12/2020
Chưa phân loại
Raspberry Pi is a single board computer. Since Docker is a containerization system, it does not need much resources to run containers. It’s very lightweight. So, Docker can be a perfect candidate for web app development and testing on Raspberry Pi. Of course, you can do other things like running a web server, proxy server or a database server etc. on Docker on Raspberry Pi single board computer.

In this article, I am going to show you how to install Docker on Raspbian OS that runs on Raspberry Pi. So, let’s get started.

Installing Raspbian OS on Raspberry Pi:

You can easily install Raspbian OS on your Raspberry Pi device.

I’ve written a dedicated article on installing Raspbian OS on Raspberry Pi. You may check it out at https://linuxhint.com/install_raspbian_raspberry_pi/.

If you don’t have an external monitor, then you can enable SSH access before you boot into Raspbian OS from your Raspberry Pi and SSH into it. I have demonstrated the process in another article of mine which you can check at https://linuxhint.com/rasperberry_pi_wifi_wpa_supplicant/.

Installing Docker on Raspbian OS:

By now you should have Raspbian OS installed on your Raspberry Pi single board computer. Now, boot into Raspbian OS.

If you’re using Raspbian OS with Desktop Environment, then open up a terminal. If you’re using Raspbian OS lite version, then connect to it using SSH.

You can connect to your Raspberry Pi through SSH using the following command:

$ ssh pi@IP_ADDR

NOTE: Here, IP_ADDR is the IP address of your Raspberry Pi.

If you’re connecting to your Raspberry Pi for the first time, then you will see the following message. Just type in yes and then press <Enter>.

Now, type in the password of your Raspberry Pi and press <Enter>.

You should be logged in to your Raspberry Pi.

Now, update the APT package repository cache of Raspbian with the following command:

$ sudo apt update

The APT package repository cache should be updated.

Now, you have to upgrade all the software package of Raspbian OS. This is an important step.

To update all the software package of Raspbian, run the following command:

$ sudo apt upgrade

Now, to confirm the update operation, press y and then press <Enter>.

The software packages are being updated as you can see. It will take a while to complete.

At this point, the software packages should be updated.

Now, you have to install the kernel headers for the Raspbian OS. This is important as if you don’t install the kernel headers, Docker won’t work.

To install the kernel headers, run the following command:

$ sudo apt install raspberrypi-kernel raspberrypi-kernel-headers

Now, press y and then press <Enter> to confirm the action.

The kernel headers should be installed.

Now, you can install Docker with the following command:

$ curl -sSL https://get.docker.com | sh

Docker is being installed. It may take a while to complete. Time for a cup of coffee!

Docker should be installed.

Now, you should add the user pi to the docker group. So, you will be able to create and manage Docker containers, images, volumes etc without sudo or super user privileges.

To add the user pi to the group docker, run the following command:

$ sudo usermod -aG docker pi

Now, you have to restart the Raspberry Pi in order for the changes to take effect.

To restart your Raspberry Pi, run the following command:

$ sudo reboot

Once your Raspberry Pi boots, connect to it using SSH again.

Then, to check whether Docker is working or not, run the following command:

$ docker version

As you can see, Docker is working perfectly.

 

Creating Your First Container:

In this section, I am going to show you how to create a Docker container. The main objective here is to show you that Docker on Raspberry Pi does work really well.

Let’s say, you want to create a nginx server container. To do that, run the following command:

$ docker run -d -p 80:80 nginx

Docker is downloading the container image as it is the first nginx container being created and the image is not cached locally yet.

The nginx container should be created.

As you can see, the container is running.

$ docker container list

Also, I can access the nginx HTTP server container from my browser.

So, that’s how you install Docker on Raspbian OS that runs on your Raspberry Pi. Thanks for reading this article.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Install MongoDB 4 on Ubuntu 18.04 LTS

MongoDB is an open source NoSQL database server. At the time of this writing, the latest version of MongoDB is v4.2. In...
29/12/2020

[MariaDB] Các thao tác cơ bản với MySQL WorkBench

MySQL Workbench là một công cụ giúp ta thao tác dễ dàng, trực quan hơn với database. Thay vì phải...
30/12/2020

Iperf command and usage

Iperf: Iperf is an open source networking tool used to measure throughput or performance of a network. It can be used to...
29/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

SỰ KHÁC BIỆT GIỮA RESIDENTIAL PROXY VÀ PROXY DATACENTER
17/02/2024

Mua Proxy v6 US Private chạy PRE, Face, Insta, Gmail
07/01/2024

Mua shadowsocks và hướng dẫn sữ dụng trên window
05/01/2024

Tại sao Proxy Socks lại được ưa chuộng hơn Proxy HTTP?
04/01/2024

Mua thuê proxy v4 nuôi zalo chất lượng cao, kinh nghiệm tránh quét tài khoản zalo
02/01/2024