Node + Java Docker Image for Raspberry Pi

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 . 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 tells docker that our image should be based on . On top of that, we use 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 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 label must begin with a TAB.

Running the above would create the image and publish it to your private repo .

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

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

Done!

That is it. Now, in your , you can use the image in your 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!

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

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store