Run the project in a Docker container
Docker is a tool that allows you to deploy applications inside of software containers. This can be useful for the Raspberry Pi because it allows users to run applications with very little overhead, as long as the application is packaged inside of a Docker image. We simply install Docker and run the container (over Raspbian/ARM).
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install curl
$ curl -sSL https://get.docker.com | sh
If we do not want to preface the docker command with sudo.
$ sudo groupadd docker
$ sudo usermod -aG docker pi
We can also run the following command to activate the changes to groups.
$ newgrp docker
We need to install debootstrap – a tool for installing a Debian-based Linux distribution into a specified directory on an existing and running operating system.
$ sudo apt-get install debootstrap
The following command will call debootstrap and install Raspbian Stretch (minimal image) into the directory "raspbian-stretch" in the current working directory:
$ sudo debootstrap --variant=minbase --arch=armhf stretch raspbian-stretch http://archive.raspbian.org/raspbian
Then, we need to convert the directory into a docker base image using:
$ sudo tar -C raspbian-stretch -c . | docker import - raspbian-stretch
From that point on you can build your docker images with your own base image by specifying the image in the Dockerfile using "FROM raspbian-stretch".
A minimal Docker image based on Alpine Linux with a complete package index and only 5 MB in size.
NOTE: We will use this B option.
$ nano Dockerfile
FROM alpine:latest
# FROM raspbian-stretch
COPY install-project.sh /
RUN sh /install-project.sh
$ docker build -t ethereum-internet-access .
$ docker container run --name=my-ethereum-internet-access ethereum-internet-access
$ docker container ls -a
NOTE: These instructions (commands) from 'sudo groupadd docker' are included in 'install-project-inside-docker-container.sh' bash script.
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install curl
$ curl -sSL https://get.docker.com | sh
$ sudo apt-get install git
$ git clone https://github.com/ethereum-internet-access/docker.git
$ cd docker
$ sh ./install-project-inside-docker-container.sh
$ docker tag ethereum-internet-access yourhubusername/ethereum-internet-access:latest
$ docker login --username=yourhubusername --password=yourpassword
$ docker push yourhubusername/ethereum-internet-access
- Write the required 'install-project.sh' bash script for the Dockerfile.
#!/bin/bash
echo "Installing project ..."