You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker构建报错:拉取opejdk镜像权限被拒,求解决方案

Fixing Your Docker Build Error

Hey there, let's work through this issue together! The error you're seeing has two clear causes, and fixing them will get your build up and running smoothly.

1. Typo in Docker Image Name

The immediate error stems from a simple typo: you wrote opejdk:11.0.7-jre instead of openjdk:11.0.7-jre. Docker Hub doesn't host an official image named opejdk, so it can't pull the resource you're requesting, hence the "pull access denied" message.

2. Missing Builder Stage Alias

Your Dockerfile uses multi-stage builds, but you didn't label the first build stage with an alias (like builder). When you try to run COPY --from=builder, Docker has no way to identify which stage to copy files from.

Corrected Dockerfile

Here's the fixed version of your Dockerfile with both issues addressed:

# First build stage - labeled as "builder" for later reference
FROM openjdk:11.0.7-jdk AS builder
RUN apt-get install -y unzip
ENV APP_HOME=/root/dev/beverage
WORKDIR $APP_HOME
COPY . $APP_HOME
WORKDIR /app
RUN curl -L https://services.gradle.org/distributions/gradle-6.5.1-bin.zip -o gradle-6.5.1-bin.zip
RUN unzip gradle-6.5.1-bin.zip
ENV GRADLE_HOME=/app/gradle-6.5.1
ENV PATH=$PATH:$GRADLE_HOME/bin
WORKDIR $APP_HOME
RUN gradle build

# Second runtime stage - corrected image name
FROM openjdk:11.0.7-jre
WORKDIR /root/
# Now we can correctly reference the "builder" stage to copy the built jar
COPY --from=builder /root/dev/beverage/build/libs/bev-all.jar .
CMD ["java", "-jar", "bev-all.jar"]

Key Changes Explained

  • Added AS builder to the first FROM line: This marks the initial build stage, making it accessible via the builder alias in subsequent stages.
  • Fixed opejdk to openjdk in the second FROM line: Docker can now pull the official, supported OpenJRE image from Docker Hub.

Once you update your Dockerfile with these tweaks, re-run docker build -t beverage . and it should complete successfully!

内容的提问来源于stack exchange,提问作者Ahmed Ali

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 18:52:50