docker curl return 文件意外结束

docker curl return unexpected end of file

我正在努力从 Centos 机器在 IBMCloud 部署我的 maven 项目,构建成功完成但是在执行 运行 命令时 "ibmcloud dev run --trace" 我收到这个错误

/bin/sh: 1: curl: not found
gzip: stdin: unexpected end of file
tar: Child returned status 1
tar: Error is not recoverable: exiting now
The command '/bin/sh -c mkdir -p /usr/share/maven /usr/share/maven/ref   && curl -fsSL http://apache.osuosl.org/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz     | tar -xzC /usr/share/maven --strip-components=1   && ln -s /usr/share/maven/bin/mvn /usr/bin/mvn' returned a non-zero code: 2
FAILED
An error exit status 2 was encountered while building the Docker image.

Dockerfile 内容

FROM ibmjava:8-sfj
LABEL maintainer="IBM Java Engineering at IBM Cloud"

COPY com.project.presentation/target/com.project.war /app.war

ARG MAVEN_VERSION=3.5.4
ARG USER_HOME_DIR="/root"

RUN mkdir -p /usr/share/maven /usr/share/maven/ref \
  && curl -fsSL http://apache.osuosl.org/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz \
    | tar -xzC /usr/share/maven --strip-components=1 \
  && ln -s /usr/share/maven/bin/mvn /usr/bin/mvn

ENV MAVEN_HOME /usr/share/maven
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"

COPY mvn-entrypoint.sh /usr/local/bin/mvn-entrypoint.sh
COPY settings-docker.xml /usr/share/maven/ref/

VOLUME "$USER_HOME_DIR/.m2"

ENV JAVA_OPTS=""
ENTRYPOINT [ "sh", "-c", "mvn -pl com.project.presentation -am spring-boot:run" ]

我根据关于此 link 的建议更新了 dockerfile 以复制设置-docker.xml 和 mvn-entrypoint.sh Docker image with Maven fails to run

图像上没有安装 curl。您可以通过简单地编写简单的 Dockerfile 来检查

FROM ibmjava:8-sfj

RUN curl google.com

现在,这将失败并给出以下错误

...
Status: Downloaded newer image for ibmjava:8-sfj
 ---> e00902e30a47
Step 2/2 : RUN curl google.com
 ---> Running in 6b08c670fad2
/bin/sh: 1: curl: not found
The command '/bin/sh -c curl google.com' returned a non-zero code: 127

通过添加以下行

在您的图像上安装 curl
RUN apk add --update \
    curl \
    && rm -rf /var/cache/apk/*