nimmis / docker-spigot

A docker container with spigot, builds spigot.jar on first start
175 stars 81 forks source link

Running container on Raspberry Pi 4 results in 'image does not match host platform' error #46

Open MWeesenaar opened 3 years ago

MWeesenaar commented 3 years ago

Hello developers,

First of all, thanks for putting the effort in making this available for the public! :-) I do have a question, however. Would it be possible to publish images for multiple architectures?

It would be beneficial for me, because then I can containerize Minecraft quite easily on my Raspberry Pi 4 8GB. I tried to clone this git, and just do docker build ., but that didn't work, see log [1]. I also attempted to use another base image (e.g. ubuntu:20.04 or debian:stretch); that resulted in the following error, where I got a bit stuck too: /bin/sh: 1: cannot create /etc/BUILDS/spigot: Directory nonexistent I tink this link could help in getting a multi-arch build: https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/

I would love to hear from you! And if there is something I can do, to make things easier - please let me know.

Output of docker version:

mikki@rpi4:~/ $ docker version
Client: Docker Engine - Community
 Version:           20.10.9
 API version:       1.41
 Go version:        go1.16.8
 Git commit:        c2ea9bc
 Built:             Mon Oct  4 16:06:55 2021
 OS/Arch:           linux/arm
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.9
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.8
  Git commit:       79ea9d3
  Built:            Mon Oct  4 16:04:47 2021
  OS/Arch:          linux/arm
  Experimental:     false
 containerd:
  Version:          1.4.11
  GitCommit:        5b46e404f6b9f661a205e28d59c982d3634148f8
 runc:
  Version:          1.0.2
  GitCommit:        v1.0.2-0-g52b36a2
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

[1]

Sending build context to Docker daemon  155.6kB
[WARNING]: Empty continuation line found in:
    RUN apt-get update &&     apt-get -y dist-upgrade &&     printf "Build of nimmis/spigot:latest, date: %!s(MISSING)\n"  `date -u +"%!Y(MISSING)-%!m(MISSING)-%!d(MISSING)T%!H(MISSING):%!M(MISSING):%!S(MISSING)Z"` > /etc/BUILDS/spigot &&     apt-get install -y wget git &&     /usr/sbin/useradd -s /bin/bash -d /minecraft -m minecraft &&     apt-get install -y locales &&     sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen &&     export CNAME=$(cat /etc/os-release | grep UBUNTU_CODENAME | cut -d = -f 2) &&     apt-get install -y wget apt-transport-https gnupg &&     wget https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public &&     gpg --no-default-keyring --keyring ./adoptopenjdk-keyring.gpg --import public &&     gpg --no-default-keyring --keyring ./adoptopenjdk-keyring.gpg --export --output adoptopenjdk-archive-keyring.gpg &&     rm public adoptopenjdk-keyring.gpg &&     mv adoptopenjdk-archive-keyring.gpg /usr/share/keyrings &&     echo "deb [signed-by=/usr/share/keyrings/adoptopenjdk-archive-keyring.gpg] https://adoptopenjdk.jfrog.io/adoptopenjdk/deb $CNAME main" |       tee /etc/apt/sources.list.d/adoptopenjdk.list &&     apt-get update &&     apt-get install -y adoptopenjdk-$JAVA_VERSION_MAJOR-$JAVA_OPT$JAVA_TYPE &&     ln -s /usr/lib/jvm/adoptopenjdk-$JAVA_VERSION_MAJOR-$JAVA_OPT$JAVA_TYPE-amd64 /usr/lib/jvm/default-jvm &&     apt-get clean all
[WARNING]: Empty continuation lines will become errors in a future release.
Step 1/8 : FROM nimmis/ubuntu:20.04
 ---> 98b0d17081a9
Step 2/8 : MAINTAINER nimmis <kjell.havneskold@gmail.com>
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v7) and no specific platform was requested
 ---> Running in a574de2885d7
Removing intermediate container a574de2885d7
 ---> 6cff0391ddc2
Step 3/8 : ENV SPIGOT_HOME=/minecraft     SPIGOT_VER=latest     SPIGOT_AUTORESTART=yes     MC_MAXMEM=     MC_MINMEM=     OTHER_JAVA_OPS=     LANG=en_US.UTF-8     LANGUAGE=en_US:en     LC_ALL=en_US.UTF-8
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v7) and no specific platform was requested
 ---> Running in e33fbaafae33
Removing intermediate container e33fbaafae33
 ---> e41b5ed6262f
Step 4/8 : ENV DEBIAN_FRONTEND noninteractive
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v7) and no specific platform was requested
 ---> Running in 0a4a4eb11fae
Removing intermediate container 0a4a4eb11fae
 ---> 12a8afccae9a
Step 5/8 : ENV JAVA_VERSION_MAJOR=16     JAVA_TYPE=""     JAVA_OPT=hotspot     JAVA_HOME=/usr/lib/jvm/default-jvm     PATH=${PATH}:/usr/lib/jvm/default-jvm/bin/
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v7) and no specific platform was requested
 ---> Running in 5184193f7f75
Removing intermediate container 5184193f7f75
 ---> 047c1961a9bc
Step 6/8 : COPY rootfs /
 ---> c08583714553
Step 7/8 : RUN apt-get update &&     apt-get -y dist-upgrade &&     printf "Build of nimmis/spigot:latest, date: %s\n"  `date -u +"%Y-%m-%dT%H:%M:%SZ"` > /etc/BUILDS/spigot &&     apt-get install -y wget git &&     /usr/sbin/useradd -s /bin/bash -d /minecraft -m minecraft &&     apt-get install -y locales &&     sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen &&     export CNAME=$(cat /etc/os-release | grep UBUNTU_CODENAME | cut -d = -f 2) &&     apt-get install -y wget apt-transport-https gnupg &&     wget https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public &&     gpg --no-default-keyring --keyring ./adoptopenjdk-keyring.gpg --import public &&     gpg --no-default-keyring --keyring ./adoptopenjdk-keyring.gpg --export --output adoptopenjdk-archive-keyring.gpg &&     rm public adoptopenjdk-keyring.gpg &&     mv adoptopenjdk-archive-keyring.gpg /usr/share/keyrings &&     echo "deb [signed-by=/usr/share/keyrings/adoptopenjdk-archive-keyring.gpg] https://adoptopenjdk.jfrog.io/adoptopenjdk/deb $CNAME main" |       tee /etc/apt/sources.list.d/adoptopenjdk.list &&     apt-get update &&     apt-get install -y adoptopenjdk-$JAVA_VERSION_MAJOR-$JAVA_OPT$JAVA_TYPE &&     ln -s /usr/lib/jvm/adoptopenjdk-$JAVA_VERSION_MAJOR-$JAVA_OPT$JAVA_TYPE-amd64 /usr/lib/jvm/default-jvm &&     apt-get clean all
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v7) and no specific platform was requested
 ---> Running in ce08eb4ac89a
standard_init_linux.go:228: exec user process caused: exec format error
The command '/bin/sh -c apt-get update &&     apt-get -y dist-upgrade &&     printf "Build of nimmis/spigot:latest, date: %s\n"  `date -u +"%Y-%m-%dT%H:%M:%SZ"` > /etc/BUILDS/spigot &&     apt-get install -y wget git &&     /usr/sbin/useradd -s /bin/bash -d /minecraft -m minecraft &&     apt-get install -y locales &&     sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen &&     export CNAME=$(cat /etc/os-release | grep UBUNTU_CODENAME | cut -d = -f 2) &&     apt-get install -y wget apt-transport-https gnupg &&     wget https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public &&     gpg --no-default-keyring --keyring ./adoptopenjdk-keyring.gpg --import public &&     gpg --no-default-keyring --keyring ./adoptopenjdk-keyring.gpg --export --output adoptopenjdk-archive-keyring.gpg &&     rm public adoptopenjdk-keyring.gpg &&     mv adoptopenjdk-archive-keyring.gpg /usr/share/keyrings &&     echo "deb [signed-by=/usr/share/keyrings/adoptopenjdk-archive-keyring.gpg] https://adoptopenjdk.jfrog.io/adoptopenjdk/deb $CNAME main" |       tee /etc/apt/sources.list.d/adoptopenjdk.list &&     apt-get update &&     apt-get install -y adoptopenjdk-$JAVA_VERSION_MAJOR-$JAVA_OPT$JAVA_TYPE &&     ln -s /usr/lib/jvm/adoptopenjdk-$JAVA_VERSION_MAJOR-$JAVA_OPT$JAVA_TYPE-amd64 /usr/lib/jvm/default-jvm &&     apt-get clean all' returned a non-zero code: 1
Duarte-Figueiredo commented 2 years ago

Hey :wave:

So I've taken a stab at this and managed to get this running on my raspberry pi 4 (8gb)

These were the steps I followed:

  1. ssh into raspberry, and git clone the nimmis/docker-spigot repo

  2. Updated the java binaries download link in the Dockerfile to use aarch64 instead of x64 (this is working for rasp4 but other rasp might required another java, you can choose from here)

    # download jdk and unpack in /usr/lib/jvm
    curl -L https://github.com/adoptium/temurin${JAVA_VERSION_MAJOR}-binaries/releases/download/jdk-${JAVA_VERSION_MAJOR}.${JAVA_VERSION_MINOR}%2B${JAVA_VERSION_UPDATE}/OpenJDK${JAVA_VERSION_MAJOR}U-jdk_aarch64_linux_${JAVA_OPT}_${JAVA_VERSION_MAJOR}.${JAVA_VERSION_MINOR}_${JAVA_VERSION_UPDATE}.tar.gz | tar xz -C /usr/lib/jvm/ && \
  3. And last, build the image using dockers buildx tool (I didn't need to install anything as buildx came with docker installation)

    docker buildx build --load --platform linux/arm64/v8 --tag spigot-arm:latest .

  4. and then you should have a spigot-arm:latest image you can docker run like the nimmis/spigot

    docker run -d -p 25565:25565 -e EULA=true spigot-arm:latest