How to Install Docker on Raspberry Pi All models

Published by Harish Kumar on

Docker on Raspberry Pi
In this segment we are going to show you How to Install Docker on Raspberry Pi for all models

What is Docker on Raspberry Pi?

Docker is a set of platform as a service (PaaS) products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels. All containers are run by a single operating-system kernel and are thus more lightweight than virtual machines.

The service has both free and premium tiers. The software that hosts the containers is called Docker Engine. It was first started in 2013 and is developed by Docker, Inc.

Source /> Wikipedia

Docker

Software Required :

   Equipment Equipment Required :

Equipment Raspberry Pi 3 & 4 “Other models are slow”

Equipment Micro SD Card 8 GB

Equipment Power Supply

Equipment Ethernet Cord for LAN Connection

hdd External Hard Drive or USB Drive

    EquipmentOptional :

Equipment Raspberry Pi Case

Equipment Keyboard

Equipment Mouse

Download & Install “Raspbian Operating System”

  • Download Raspbian OS from Official Website : raspberrypi.org
  • Then write the image to the SD Card using : Etcher
  • Now, Boot the Raspberry Pi with this SD Card, Follow the On-Screen Instructions.

Enabling SSH in Raspbian OS

  • By default SSH is disabled in Raspbian. So, we need to enable it from desktop.
  • Launch Raspberry Pi Configuration.
  • Navigate to the Interfaces tab
  • Select Enabled next to SSH.
  • Click OK.
ssh

Enabling SSH in Raspbian OS through Terminal

  • Enter sudo raspi-config in a terminal window.
sudo raspi-config
  • Select Interfacing Options.
ssh
  • Navigate to and select SSH.
ssh
  • Choose Yes –> Ok –> Finish

Enabling SSH in Raspbian OS through Commands

sudo systemctl enable ssh
sudo systemctl start ssh

Setup Docker on Raspberry Pi

  • To setup Docker on Raspberry Pi we need to remove some errors to work it properly.

Update & Upgrade Raspbian OS

  • Now, we need to open Terminal, then update and upgrade our Raspbian OS.
sudo apt-get update && sudo apt-get upgrade

Install Docker

  • Type the command to install Docker.
curl -sSL https://get.docker.com | sh

Add permission to Pi User to run Docker Commands

  • Add “pi” user to “docker” group using the following command :
sudo usermod -aG docker pi

Checking Docker Version

  • To check the Docker version, we need to type : docker version
Pi@raspberrypi:~ $ docker version
 Client:
 Version:           18.09.0
 API version:       1.39
 Go version:        go1.10.4
 Git commit:        4d60db4
 Built:             Wed Nov  7 00:57:21 2018
 OS/Arch:           linux/arm
 Experimental:      false

 Server: Docker Engine - Community
 Engine:
  Version:          18.09.0
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.4
  Git commit:       4d60db4
  Built:            Wed Nov  7 00:17:57 2018
  OS/Arch:          linux/arm
  Experimental:     false

 Remove Docker Errors

Checking Docker Info

  • To check the Docker Info & Errors, we need to type : docker Info
pi@raspberrypi:~ $ docker info
Containers: 3
 Running: 0
 Paused: 0
 Stopped: 3
Images: 6
Server Version: 18.09.0
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: c4446665cb9c30056f4998ed953e6d4ff22c7c39
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.14.79-v7+
Operating System: Raspbian GNU/Linux 9 (stretch)
OSType: linux
Architecture: armv7l
CPUs: 4
Total Memory: 927.2MiB
Name: raspberrypi
ID: JS5G:RZ5S:W5N7:IZQE:JW3D:A65I:O6JN:666N:7W6F:4V7U:T2MO:OKPQ
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

WARNING: No memory limit support
WARNING: No swap limit support
WARNING: No kernel memory limit support
WARNING: No oom kill disable support
WARNING: No cpu cfs quota support
WARNING: No cpu cfs period support
  • Now, we need to edit /boot/cmdline.txt file
sudo nano /boot/cmdline.txt
  • Now, add two parameters : cgroup_enable=memory swapaccount=1 at the end of these lines and reboot
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=85da7cb8-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles

Testing Docker & Adding Containers

  • Now add Hello-world container by the following command
pi@raspberrypi:~ $ docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (arm32v7)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

 Other Useful Docker Commands

List Docker Container

  • To list all Docker Containers, we need to type :
docker ps -a

Restart Docker Container

  • To restart a Container, we need to type :
docker restart "container name or ID"

Rename Docker Container

  • To rename a Container, we need to type :
docker rename "container name or ID"

Removing Containers from Docker

  • To remove the Container we need to type the command :
docker rm "container name or ID"

Uninstall Docker

  • To uninstall Docker we need to run these commands :
sudo apt-get purge docker-ce
sudo rm -rf /var/lib/docker

Execute Docker Pull Images

  • To execute Docker pull images we need to run these commands :
docker exec -it image name sh

Access Docker Container

  • To access files inside Docker container we need to run this command :
docker exec -it "Container Name or ID" bash

Check Docker Images

  • To access downloaded images we need to run this command :
docker images

Access Docker Container

  • To remove downloaded images we need to run this command :
docker rmi "Image Name"

Now, You are ready to use Docker on Raspberry Pi.
Enjoy using Docker and share your thoughts. 
Smile (“_”)

Please checkout my other articles:

Pi-Hole on Docker using OMV Raspberry Pi 4 “Network Wide Ad-Blocker”OpenMediaVault 5 on Raspberry Pi

Plex Media Server on Docker for Raspberry Pi All ModelsOpenMediaVault 5 on Raspberry Pi

Did you Like my Work ?

Please Like, Share and Subscribe our YouTube Channel.


Harish Kumar

As a founder of the PcMac YouTube channel and website, Our goal is to provide Free Technical help to people and spread knowledge to everyone.

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *