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 the 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 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
Software Required :
Equipment Required | Optional | ||
Raspberry Pi 4 | Case | ||
SD Card | Raspberry Pi Keyboard | ||
Ethernet Cable | Mouse | ||
Power Adapter | |||
External HDD | |||
Shop now |
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 the desktop.
- Launch the Raspberry Pi Configuration.
- Navigate to the Interfaces tab
- Select Enabled next to SSH.
- Click OK.
Enabling SSH in Raspbian OS through Terminal
- Enter sudo raspi-config in a terminal window.
sudo raspi-config
- Select Interfacing Options.
- Navigate to and select 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 set up 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 the “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
Remove Docker Image
- 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 check out my other articles:
- Pi-Hole on Docker using OMV Raspberry Pi 4 “Network-Wide Ad-Blocker”
- Plex Media Server on Docker for Raspberry Pi All Models
Did you find us helpful?
Subscribe our YouTube Channel | |
Support us on Patreon | |
Like us on Facebook | |
Share This Article with others |