Home > OS >  Build Docker Image OpenJDK16 for ARM on Gitlab Runners
Build Docker Image OpenJDK16 for ARM on Gitlab Runners

Time:11-12

I'm currently working on a Java application that I run on my Raspberry 3B (arm32v7). I'm building my JAR on Java 14 and building a Docker Image using this Dockerfile

FROM arm32v7/adoptopenjdk:14.0.2_8-jdk-hotspot-bionic
COPY /build/libs/project-1.0-SNAPSHOT.jar my-jar.jar
CMD java -jar my-jar.jar

This is working pretty fine. I'm using Gitlab CI to build my jar and my Docker Image, using the following :

image: openjdk:14-jdk-slim
    
before_script:
  - export GRADLE_USER_HOME=`pwd`/.gradle

stages:
  - build
  - package

gradle-build:
  stage: build
  script: "./gradlew build"
  artifacts:
    paths:
      - build/libs/*.jar

docker-build:
  image: docker:stable
  services:
    - docker:dind
  stage: package
  before_script:
    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
  script:
    - export DOCKER_HOST=tcp://docker:2375/
    - docker build -t registry.gitlab.com/mygitlab/project .
    - docker push registry.gitlab.com/mygitlab/project
  tags:
    - docker

The problem is that everytime I tried to upgrade my version of Java in my Docker image, I get the following error :

Step 1/4 : FROM arm32v7/adoptopenjdk:16-jre 16-jre: Pulling from arm32v7/adoptopenjdk no manifest for linux/amd64 in the manifest list entries

I'm having this issue with a lot of arm32v7 compatible images. In fact, the one that I'm using right now seems to be the only one working.

I'm still a beginner on Docker and I'm not sure to understand clearly my problem. For my understanding, the Gitlab Runner that I'm using can't figure out the image I'm trying to use, but how can I change that ?

Thank you for your help.

CodePudding user response:

no manifest for linux/amd64 in the manifest list entries

When you pull docker images, docker checks the manifest in dockerhub to see if there is an image that matches the architecture of your system.

GitLab CI runners run on linux/amd64 architecture, not ARM. You can't pull/run images for other platforms. The repository arm32v7/adoptopenjdk is only available for the ARM CPU architecture. So, you are unable to pull that image on gitlab runners.

Some things you can do:

  1. Use the multi-architecture repository in your dockerfile's FROM line like adoptopenjdk (or its replacement enter image description here

    However, if you are making derivative images and you intend to push them to your registry and pull them on your raspberry pi, you will still need to build both architectures and push them to your registry (e.g. using docker buildx for multi-arch builds) as mentioned above in (3).

  • Related