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

How to Change Screen Resolution on Ubuntu

Screen resolution is an important factor in enjoying your system. For allowing us, humans, to perform tasks, we have to...
29/12/2020

What happens when GNOME Starts

When you have GNOME installed, it is usually set up to run at boot. Your distribution has a standard desktop at your disposal....
29/12/2020

Install Redis From Docker Hub

Overview In this post, we will see how we can install and use Redis server from  Docker Hub. Using Docker Hub is very...
28/12/2020
Bài Viết

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

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn
03/06/2024

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh
03/06/2024

Mua proxy Onet uy tín tại Onet.com.vn
03/06/2024

Thuê mua IPv4 giá rẻ, tốc độ nhanh, uy tín #1
28/05/2024

Thuê địa chỉ IPv4 IPv6 trọn gói ở đâu chất lượng, giá RẺ nhất?
27/05/2024