Spring Sample on Docker (for M1 Chip)

In this post, I am going to run a sample Spring application, which was created at: REST with Spring: Quick Start .

Assuming that you have the jar file at: ./build/libs/rest-service-0.0.1-SNAPSHOT.jar


Prepare Docker Files

% vim Dockerfile
FROM arm64v8/openjdk
ADD ./build/libs/rest-service-0.0.1-SNAPSHOT.jar greeting.jar
CMD java -jar greeting.jar
Note: arm64v8/openjdk is for M1 Chip. This solved the following build error:

"The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8)"


% vim docker-compose.yml
version: "3.9"
services:
  web:
    build: .
    ports:
      - "80:8080"

Build & Run

% docker-compose up --build

% curl http://localhost/greeting

{"id":1,"content":"Hello, World!"}


Comments

Popular posts from this blog

Minikube Installation for M1 Mac

Selenide: Quick Start

PyCharm: Quick Start