Node + Java Docker Image for Raspberry Pi

Charles Chan
2 min readMar 23, 2020

Simple Docker image for a Node + Java environment.

As I continue to build on my Raspberry Pi Infrastructure, I need to create a Docker image that contains both Java and Node. Unfortunately, no such thing exist as an official image and I don’t like using images created by others due to security concern. So, I will have to do it myself and you can do it too.

Dockerfile

The first step to create a docker image is to have a Dockerfile . The content of the file tells docker what to do. Here is what it looks like:

FROM arm32v7/node:10.19.0
RUN apt update && apt install -y openjdk-8-jdk

This Dockerfile tells docker that our image should be based on arm32v7/node:10.19.0 . On top of that, we use apt to install JDK 8. There is nothing fancy except that you’d need to find the right architecture for your base. Although Raspberry Pi has a 64 bit CPU, the OS (Raspbian) is a 32 bit ARM OS.

Private Registry

To build and push this docker image to my private repo, I need to use a handful of commands. To reduce the amount of repeated typing and errors, I use a Makefile to help me:

REPOSITORY=node-10-jdk-8
TAG=latest
REGISTRY=server.local:5000
default:
-docker rmi $(REPOSITORY):$(TAG)
-docker rmi $(REGISTRY)/$(REPOSITORY):$(TAG)
docker build . -t $(REPOSITORY):$(TAG)
docker tag $(REPOSITORY):$(TAG) $(REGISTRY)/$(REPOSITORY):$(TAG)
docker push $(REGISTRY)/$(REPOSITORY):$(TAG)

Notice that each line under the default: label must begin with a TAB.

Running the above Makefile would create the image and publish it to your private repo server.local:5000 .

If you are building this image on your Mac and your private repository is non-TLS, you will need to create a file ~/.docker/daemon.json with the following content:

{
"insecure-registries": ["server.local:5000"]
}

Done!

That is it. Now, in your Jenkinsfile , you can use the image in your agent line:

agent {
docker {
image 'server.local:5000/node-10-jdk-8:latest'
...
}
}

Summary

We have demonstrated how to create a Docker image for a Node + Java environment for Raspberry Pi. The Docker image is pushed to your private repository and can be pulled into your Jenkins build when needed.

Happy Programming. Enjoy!

--

--

Charles Chan

A seasoned consultant specialized in Software Development and Architecture. Charles also loves to tavel, follow him on https://www.gorestrepeat.com/