docker-compose showing ERROR [web internal] load metadata. Redis on Mac M2

490 views Asked by At
docker-compose up

returns:

[+] Building 1.7s (4/4) FINISHED                                 docker:default
 => [web internal] load .dockerignore                                      0.0s
 => => transferring context: 2B                                            0.0s
 => [web internal] load build definition from Dockerfile                   0.0s
 => => transferring dockerfile: 701B                                       0.0s
 => ERROR [web internal] load metadata for docker.io/library/openjdk:17-a  1.7s
 => [web auth] library/openjdk:pull token for registry-1.docker.io         0.0s
------
 > [web internal] load metadata for docker.io/library/openjdk:17-alpine:
------
failed to solve: openjdk:17-alpine: no match for platform in manifest sha256:4b6abae565492dbe9e7a894137c966a7485154238902f2f25e9dbd9784383d81: not found

Having researched, it seems like the problem is with the compatibility (I am using Mac, the image was built from Windows). I tried changing the parameters like platform linux/x86_64 and doing rm ~/.docker/config.json and etc as suggested in forums, though the error still showing up.

How can I run docker-compose?

Dockerfile:

#pulling base image and updating apk
FROM openjdk:17-alpine
RUN apk update && \
    apk add --no-cache tzdata

#making directory for jar and transfer it
RUN mkdir /opt/app
COPY target/dormitory_marketplace-0.0.1-SNAPSHOT.jar /opt/app/dm.jar
WORKDIR /opt/app

#running jar
CMD java -jar dm.jar

docker-compose.yml:

version: "3"

services:
    web:
        build: .
        container_name: web
        ports:
            - "8080:8080"
        depends_on:
            - redis
        environment:
            REDIS_HOST: redis

    redis:
        container_name: redis
        image: "redis:latest"
1

There are 1 answers

0
Pino On

openjdk:17-alpine is available for amd64 only, not arm64, and is also deprecated. Use eclipse-temurin:17 or, even better, eclipse-temurin:17-jre (your Dockerfile suggests that a JRE is enough for you) instead; they are based on Ubuntu Jammy. If you prefer Alpine you can use amazoncorretto:17-alpine but it does not provide a JRE; to create it by yourself see, for example, How to create an Alpine-based JRE-only Docker image of Amazon Corretto?