curl命令无法在dockerfile中使用,但可以在同一网络中使用

时间:2019-02-17 12:46:18

标签: docker dockerfile

我正在编写docker文件来安装Java和声纳。在安装Java之前,一切都很好。但是当使用 curl 开始下载声纳时,失败。更令人沮丧的是,完全相同的命令可在docker文件外部,相同的shell提示符下以及相同的网络上运行。

我真的很困惑如何发生。我没有得到什么愚蠢的错误。

请参阅dockefile:

FROM centos:7

ENV JAVA_VERSION 8u201
ENV BUILD_VERSION b09

RUN yum -y install wget; wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/$JAVA_VERSION-$BUILD_VERSION/42970487e3af4f5aa5bca3f542482c60/jdk-$JAVA_VERSION-linux-x64.rpm" -O /tmp/jdk-8-linux-x64.rpm; yum -y install /tmp/jdk-8-linux-x64.rpm

# JDK stripping
RUN rm -f /usr/java/jdk1.8.0_201/src.zip /usr/java/jdk1.8.0_201/javafx-src.zip
RUN rm -rf /usr/java/jdk1.8.0_201/lib/missioncontrol/ /usr/java/jdk1.8.0_201/lib/visualvm/ /usr/java/jdk1.8.0_201/db/

RUN alternatives --install /usr/bin/java java /usr/java/latest/bin/java 1
RUN alternatives --install /usr/bin/javac javac /usr/java/latest/bin/javac 1

ENV JAVA_HOME /usr/java/latest
ENV PATH=$PATH:/usr/java/latest/bin/java
RUN echo "$PATH"

RUN rm -f /tmp/jdk-8-linux-x64.rpm; yum -y remove wget; yum -y clean all

ENV SONAR_VERSION=7.6 \
    SONARQUBE_HOME=/opt/sonarqube \
    SONARQUBE_JDBC_USERNAME=sonar \
    SONARQUBE_JDBC_PASSWORD=sonar \
    SONARQUBE_JDBC_URL=

# Http port
EXPOSE 9000

RUN groupadd -r devopsadmin && useradd -r -g devopsadmin devopsadmin


RUN set -x \
    && cd /opt \
    && curl -o sonarqube.zip -fSL https://binaries.sonarsource.com/CommercialDistribution/sonarqube-enterprise/sonarqube-enterprise-$SONAR_VERSION.zip \
    && curl -o sonarqube.zip.asc -fSL https://binaries.sonarsource.com/CommercialDistribution/sonarqube-enterprise/sonarqube-enterprise-$SONAR_VERSION.zip.asc \
    && /bin/bash /usr/bin/unzip /opt/sonarqube.zip \
    && mv sonarqube-$SONAR_VERSION sonarqube \
    && chown -R devopsadmin:devopsadmin sonarqube \
    && rm sonarqube.zip* \
    && rm -rf $SONARQUBE_HOME/bin/*

VOLUME "$SONARQUBE_HOME/data"

WORKDIR $SONARQUBE_HOME
COPY run.sh $SONARQUBE_HOME/bin/
USER devopsadmin
ENTRYPOINT ["./bin/run.sh"]

请提出建议

编辑1:

查看整个日志:

Step 14/21 : EXPOSE 9000
 ---> Using cache
 ---> 6d8df8bfdaf5
Step 15/21 : RUN groupadd -r devopsadmin && useradd -r -g devopsadmin devopsadmin
 ---> Using cache
 ---> 4d1a28e9288c
Step 16/21 : RUN set -x     && cd /opt     && curl -o sonarqube.zip -fSL https://binaries.sonarsource.com/CommercialDistribution/sonarqube-enterprise/sonarqube-enterprise-$SONAR_VERSION.zip     && curl -o sonarqube.zip.asc -fSL https://binaries.sonarsource.com/CommercialDistribution/sonarqube-enterprise/sonarqube-enterprise-$SONAR_VERSION.zip.asc     && /bin/bash /usr/bin/unzip /opt/sonarqube.zip     && mv sonarqube-$SONAR_VERSION sonarqube     && chown -R devopsadmin:devopsadmin sonarqube     && rm sonarqube.zip*     && rm -rf $SONARQUBE_HOME/bin/*
 ---> Running in 2e0d5ad30767
+ cd /opt
+ curl -o sonarqube.zip -fSL https://binaries.sonarsource.com/CommercialDistribution/sonarqube-enterprise/sonarqube-enterprise-7.6.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:19 --:--:--     0curl: (6) Could not resolve host: binaries.sonarsource.com; Unknown error
The command '/bin/sh -c set -x     && cd /opt     && curl -o sonarqube.zip -fSL https://binaries.sonarsource.com/CommercialDistribution/sonarqube-enterprise/sonarqube-enterprise-$SONAR_VERSION.zip     && curl -o sonarqube.zip.asc -fSL https://binaries.sonarsource.com/CommercialDistribution/sonarqube-enterprise/sonarqube-enterprise-$SONAR_VERSION.zip.asc     && /bin/bash /usr/bin/unzip /opt/sonarqube.zip     && mv sonarqube-$SONAR_VERSION sonarqube     && chown -R devopsadmin:devopsadmin sonarqube     && rm sonarqube.zip*     && rm -rf $SONARQUBE_HOME/bin/*' returned a non-zero code: 6
[devopsadmin@be-deb-prod-cicdtoold-vm newsonar]$ curl -o sonarqube.zip -fSL https://binaries.sonarsource.com/CommercialDistribution/sonarqube-enterprise/sonarqube-enterprise-7.6.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  252M  100  252M    0     0  26.5M      0  0:00:09  0:00:09 --:--:-- 32.1M

0 个答案:

没有答案