docker curl返回文件的意外结尾

问题描述 投票:0回答:1

我正在从Centos Machine到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" ]

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

dockerfile command-line-interface ibm-cloud maven-3 centos8
1个回答
1
投票

图像上未安装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/*
© www.soinside.com 2019 - 2024. All rights reserved.