Although the example in this guide focuses on a cloud-based application, the same flow applies to at-scale embedded use-cases as well.
The benefits of abstracting hardware differences during development and using the Arm architecture also apply in the embedded space. Docker makes software deployment for IoT and embedded systems easier because you do not need to flash individual boards, install necessary dependencies, or build scripts to copy files to boards. Downloading and running a Docker image ensures environment consistency and simplifies deployment across embedded or IoT devices.
Let's run the same PHP example application on a Raspberry Pi 3 or a Raspberry Pi 4. Some boards may require some minor Linux kernel modifications to ensure that the Docker engine can run properly. The Raspberry Pi running Raspbian will run Docker with no configuration changes. Follow installation instructions to install Raspbian and boot the Raspberry Pi from an SD card.
The instructions to run the PHP example application are the same as the AWS A1 instance.The only difference is that Raspbian runs only 32-bit images.
Follow these steps:
- Enable the ssh server and connect to the board.
- Run the same commands that you ran on the A1 instance, as you can see in the following code:
$ sudo apt-get update $ sudo apt-get upgrade $ curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh $ sudo usermod -aG docker $USER
- Add the pi user to the docker group to avoid needing sudo to run the docker command.
- Log out and back in again.
- Test the install with a quick hello-world run, as you can see here:
$ docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world c1eda109e4da: Already exists Digest: sha256:92695bc579f31df7a63da6922075d0666e565ceccad16b59c3374d2cf4e8e50e Status: Downloaded newer image for hello-world:latest 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/
- Run the PHP example application. The example application is the same as it was with Docker Desktop on Windows or Mac, on the AWS A1 Arm server, and on the Raspberry Pi.
$ docker run --rm -it -p 80:80 jasonrandrews/php-example
- Open a browser on the Raspberry Pi, or on another computer on the network, and enter in the IP address of the Pi. You will see the same PHP example application appear, but this time the response shows the uname as armv7l. The same command runs the PHP example application on the Windows, or Mac, desktop, the Arm server in AWS, and the Raspberry Pi.