Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”
The springboot project was recently deployed on raspberry PI using Docker, but an error was reported because the JDK downloaded directly is not supported. So let’s take a look at the previous Docker file
FROM Java :8 ADD meeting-0.0.1- snapshot. jar/meeting-1.0-snapshot. jar EXPOSE 8084 ENTRYPOINT [" Java ", "-jar", "/ the meeting - 1.0 - the SNAPSHOT. Jar", 1234 ""]Copy the code
Java obtained from docker image website is 64-bit, raspberry PI 32-bit system does not work, so you need to create a mirror.
- First I went to Oracle and downloaded a 32-bit ARM image, which I did
jdk-8u241-linux-arm32-vfp-hflt.tar.gz
, be careful not to download wrong. - Decompress the image and place it in the Linux
/usr/lib/jvm
folder - Open the file
~/.bashrc
, add the following content
Bashrc 1 export JAVA_HOME=/usr/lib/ JVM /jdk1.8.0_241 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH 1234Copy the code
- Check whether it takes effect.
source ~/.bashrc
java -version
12
Copy the code
- Dockerfile:
#Docker image of JDK8 in ARM32 # VERSION 8 # Author: FROM buildpack-deps:stretch-scm # author MAINTAINER Yuwen <[email protected]> # Default to UTF-8 file.encoding ENV LANG C.UTF-8 ENV JAVA_HOME /usr/local/jdk8 ENV PATH $JAVA_HOME/bin:$PATH ENV JDK_FILE jdk-8u241-linux-arm32-vfp-hflt.tar.gz COPY $JDK_FILE /usr/local/ RUN mkdir -p "$JAVA_HOME"; \ tar --extract \ --file /usr/local/$JDK_FILE \ --directory "$JAVA_HOME" \ --strip-components 1 \ --no-same-owner; \ rm /usr/local/$JDK_FILE 1234567891011121314151617181920Copy the code
Among them, “from” should not be modified, the author can modify, and the rest should not be changed.
- Copy the Dockerfile file to the same directory as the downloaded image and create the imageThen run the command to create the image:
docker build -t arm32jdk:8 .
1
Copy the code
\7. We can use the JDK image to deploy the Springboot project.
FROM arm32JDK :8 ADD meeting-0.0.1- snapshot. jar/meeting-1.0-snapshot. jar EXPOSE 8084 ENTRYPOINT [" Java ", "-jar", "/ the meeting - 1.0 - the SNAPSHOT. Jar", 1234 ""]Copy the code
- After creating my own image, I also encountered a problem in creating the container. The default time zone for creating the container is medium time zone, which is (UTC+0).Create a container in Shanghai (UTC+8).
docker run --name meeting -e TZ="Asia/Shanghai" -p 8084:8084 -d --restart=always meeting
1
Copy the code
Then enter the container to review the time zone:
docker exec -i -t gateway-server /bin/bash
date -R
12
Copy the code