You can Setup and work with Docker on Raspberry Pi. Let see how you can setup your Raspberry Pi and run your first container on it.
First You need a Raspberry Pi with Raspberry Pi OS (formaly Raspbian OS) . If Your is not ready, You canDownload Raspberry Pi OS from Raspberrypi.org ‘s download section: https://www.raspberrypi.org/downloads/raspbian/. You need to flash this downloaded image to the micro SD card. Assuming your laptop has a SD card slot, you need a flashing software like etcher. Go ahead and download from: https://etcher.io/
Recommended: How To Use Raspberry pi in a truely headless mode
Setup Docker on Raspberry Pi
Now Your Pi Ready, Open terminal and follow given below Steps.
1. Update Packages:
Update Raspberry Pi packages using the following command –
sudo apt-get update && sudo apt-get upgrade
2. Install Docker:
Install Docker using following command –
curl -sSL https://get.docker.com | sh
3. Add permission to User to run Docker Commands:
Add “pi” user to “docker” group using the following command –
sudo usermod -aG docker pi
You must Log off from Raspberry Pi and Login again, for this to take effect.
4. Verify Installation:
Check Docker installation using the “docker –version” command. If you see the correct version, you are good to go.
pi@RPi:~ $ docker --version Docker version 17.05.0-ce, build 89658be pi@RPi:~ $
5. Run Hello-World Program:
Run the ARM-based “hello-word” Docker container using “docker run armhf/hello-world” command. All the Docker Images under the namespace armhf are created by Docker team.
You can NOT run the default “hello-world” container (using “docker run hello-world” command) on Raspberry Pi as it is created for X86 Architecture and won’t work on ARM architecture based Raspberry Pi.
On successful execution, you should see following output on your Raspberry Pi –
pi@RPi:~ $ docker run armhf/hello-world Unable to find image 'armhf/hello-world:latest' locally latest: Pulling from armhf/hello-world a0691bf12e4e: Pull complete Digest: sha256:9701edc932223a66e49dd6c894a11db8c2cf4eccd1414f1ec105a623bf Status: Downloaded newer image for armhf/hello-world:latest Hello from Docker on armhf! 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. 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 Hub account: https://hub.docker.com For more examples and ideas, visit: https://docs.docker.com/engine/userguide/ pi@RPi:~ $
- If you see the following error, reboot your Raspberry Pi and try again –
docker: Error response from daemon: failed to create endpoint compassionate_joliot on network bridge: failed to add the host (veth0685c4b) <=> sandbox (vethccfe136) pair interfaces: operation not supported. ERRO error getting events from daemon: net/http: request canceled
- If you see the following error, it means you are trying to run an X86 container on ARM machine i.e. Raspberry Pi. This is because the binary format used by ARM is not compatible with x86.
standard_init_linux.go:178: exec user process caused "exec format error"
I hope you like this post”Setup Docker on Raspberry Pi”. Do you have any questions? Leave a comment down below!
Thanks for reading. If you like this post probably you might like my next ones, so please support me by subscribing my blog.