在Docker映像中安装声纳扫描仪时出错

时间:2020-05-11 21:42:39

标签: .net docker sonarqube

我试图在Docker映像中安装声纳扫描仪,但在Docker Hub上的构建中始终出现以下错误。

Tool 'dotnet-sonarscanner' failed to install. This failure may have been caused by:
* You are attempting to install a preview release and did not use the --version option to specify the version.
* A package by this name was found, but it was not a .NET Core tool.
* The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
* You mistyped the name of the tool.
[0m
Removing intermediate container 883a2e55cda3
The command '/bin/sh -c dotnet tool install --global dotnet-sonarscanner --version 4.9.0' returned a non-zero code: 1

我可以在本地正常运行,偶尔Docker Hub构建会成功。我需要Docker Hub自动构建才能持续成功,而造成这种情况的原因我茫然无措。

Dockerfile:

FROM john0879/jnlp-aws-yarn

USER root

# Install .NET CLI dependencies
RUN echo 'deb http://deb.debian.org/debian stretch main' >> /etc/apt/sources.list
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
    libc6 \
    libgcc1 \
    libgssapi-krb5-2 \
    libicu57 \
    liblttng-ust0 \
    libssl1.0.2 \
    libstdc++6 \
    zlib1g \
    && rm -rf /var/lib/apt/lists/* sudo

# Install .NET Core SDK
ENV DOTNET_SDK_VERSION 2.1.804

RUN curl -SL --output dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-x64.tar.gz \
    && dotnet_sha512='82b039856dadd2b47fa56a262d1a1a389132f0db037d4ee5c0872f2949c2cd447c33a978e1f532783119aa416860e03f26b840863ca3a97392a4b77f8df5bf66' \
    && echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \
    && mkdir -p /usr/share/dotnet \
    && tar -zxf dotnet.tar.gz -C /usr/share/dotnet \
    && rm dotnet.tar.gz \
    && ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet

# Trigger first run experience by running arbitrary cmd to populate local package cache
RUN dotnet help

USER jenkins

RUN dotnet tool install --global dotnet-sonarscanner --version 4.9.0
RUN echo '#!/bin/bash\n\
cat << \EOF >> ~/.bash_profile\n\
export PATH="$PATH:/home/jenkins/.dotnet/tools"\n\
EOF\n'\
> ~/updatePath.sh
RUN chmod a+x updatePath.sh
RUN ./updatePath.sh
RUN rm ./updatePath.sh

完整输出:

Cloning into '.'...
Warning: Permanently added the RSA host key for IP address '140.82.112.3' to the list of known hosts.
Reset branch 'master'
Your branch is up-to-date with 'origin/master'.
Pulling cache layers for index.docker.io/john0879/jnlp-aws-yarn-dotnet:latest...
Done!
KernelVersion: 4.4.0-1060-aws
Components: [{u'Version': u'18.03.1-ee-3', u'Name': u'Engine', u'Details': {u'KernelVersion': u'4.4.0-1060-aws', u'Os': u'linux', u'BuildTime': u'2018-08-30T18:42:30.000000000+00:00', u'ApiVersion': u'1.37', u'MinAPIVersion': u'1.12', u'GitCommit': u'b9a5c95', u'Arch': u'amd64', u'Experimental': u'false', u'GoVersion': u'go1.10.2'}}]
Arch: amd64
BuildTime: 2018-08-30T18:42:30.000000000+00:00
ApiVersion: 1.37
Platform: {u'Name': u''}
Version: 18.03.1-ee-3
MinAPIVersion: 1.12
GitCommit: b9a5c95
Os: linux
GoVersion: go1.10.2
Starting build of index.docker.io/john0879/jnlp-aws-yarn-dotnet:latest...
Step 1/13 : FROM john0879/jnlp-aws-yarn
---> c7b3d2909440
Step 2/13 : USER root
---> Running in 3b3611ed5848
Removing intermediate container 3b3611ed5848
---> e1bb30ad95c2
Step 3/13 : RUN echo 'deb http://deb.debian.org/debian stretch main' >> /etc/apt/sources.list
---> Running in 5177eb7c9efe
Removing intermediate container 5177eb7c9efe
---> 03086de1c221
Step 4/13 : RUN apt-get update && apt-get install -y --no-install-recommends libc6 libgcc1 libgssapi-krb5-2 libicu57 liblttng-ust0 libssl1.0.2 libstdc++6 zlib1g && rm -rf /var/lib/apt/lists/* sudo
---> Running in 5262780108a3
Hit:1 http://security.debian.org/debian-security buster/updates InRelease
Hit:2 http://deb.debian.org/debian buster InRelease
Get:3 http://deb.debian.org/debian buster-updates InRelease [49.3 kB]
Ign:4 http://deb.debian.org/debian stretch InRelease
Get:5 http://deb.debian.org/debian stretch-backports InRelease [91.8 kB]
Get:6 http://deb.debian.org/debian stretch Release [118 kB]
Get:7 http://deb.debian.org/debian stretch Release.gpg [2410 B]
Get:8 http://deb.debian.org/debian stretch/main amd64 Packages [7083 kB]
Fetched 7345 kB in 7s (990 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
libgcc1 is already the newest version (1:8.3.0-6).
libgcc1 set to manually installed.
libstdc++6 is already the newest version (8.3.0-6).
libstdc++6 set to manually installed.
libc6 is already the newest version (2.28-10).
libc6 set to manually installed.
libgssapi-krb5-2 is already the newest version (1.17-3).
libgssapi-krb5-2 set to manually installed.
zlib1g is already the newest version (1:1.2.11.dfsg-1).
zlib1g set to manually installed.
The following additional packages will be installed:
liblttng-ust-ctl4 liburcu6
The following NEW packages will be installed:
libicu57 liblttng-ust-ctl4 liblttng-ust0 libssl1.0.2 liburcu6
0 upgraded, 5 newly installed, 0 to remove and 12 not upgraded.
Need to get 9358 kB of archives.
After this operation, 35.9 MB of additional disk space will be used.
Get:1 http://deb.debian.org/debian stretch/main amd64 libssl1.0.2 amd64 1.0.2u-1~deb9u1 [1304 kB]
Get:2 http://deb.debian.org/debian stretch/main amd64 libicu57 amd64 57.1-6+deb9u3 [7705 kB]
Get:3 http://deb.debian.org/debian buster/main amd64 liburcu6 amd64 0.10.2-1 [66.4 kB]
Get:4 http://deb.debian.org/debian buster/main amd64 liblttng-ust-ctl4 amd64 2.10.3-1 [105 kB]
Get:5 http://deb.debian.org/debian buster/main amd64 liblttng-ust0 amd64 2.10.3-1 [177 kB]
[91mdebconf: delaying package configuration, since apt-utils is not installed
[0m
Fetched 9358 kB in 1s (15.2 MB/s)
Selecting previously unselected package libssl1.0.2:amd64.
(Reading database ...
(Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95% (Reading database ... 100% (Reading database ... 18833 files and directories currently installed.)
Preparing to unpack .../libssl1.0.2_1.0.2u-1~deb9u1_amd64.deb ...
Unpacking libssl1.0.2:amd64 (1.0.2u-1~deb9u1) ...
Selecting previously unselected package libicu57:amd64.
Preparing to unpack .../libicu57_57.1-6+deb9u3_amd64.deb ...
Unpacking libicu57:amd64 (57.1-6+deb9u3) ...
Selecting previously unselected package liburcu6:amd64.
Preparing to unpack .../liburcu6_0.10.2-1_amd64.deb ...
Unpacking liburcu6:amd64 (0.10.2-1) ...
Selecting previously unselected package liblttng-ust-ctl4:amd64.
Preparing to unpack .../liblttng-ust-ctl4_2.10.3-1_amd64.deb ...
Unpacking liblttng-ust-ctl4:amd64 (2.10.3-1) ...
Selecting previously unselected package liblttng-ust0:amd64.
Preparing to unpack .../liblttng-ust0_2.10.3-1_amd64.deb ...
Unpacking liblttng-ust0:amd64 (2.10.3-1) ...
Setting up libssl1.0.2:amd64 (1.0.2u-1~deb9u1) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
Setting up libicu57:amd64 (57.1-6+deb9u3) ...
Setting up liburcu6:amd64 (0.10.2-1) ...
Setting up liblttng-ust-ctl4:amd64 (2.10.3-1) ...
Setting up liblttng-ust0:amd64 (2.10.3-1) ...
Processing triggers for libc-bin (2.28-10) ...
Removing intermediate container 5262780108a3
---> 9748973a9ed4
Step 5/13 : ENV DOTNET_SDK_VERSION 2.1.804
---> Running in 59204246358f
Removing intermediate container 59204246358f
---> a416cfb9d431
Step 6/13 : RUN curl -SL --output dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-x64.tar.gz && dotnet_sha512='82b039856dadd2b47fa56a262d1a1a389132f0db037d4ee5c0872f2949c2cd447c33a978e1f532783119aa416860e03f26b840863ca3a97392a4b77f8df5bf66' && echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - && mkdir -p /usr/share/dotnet && tar -zxf dotnet.tar.gz -C /usr/share/dotnet && rm dotnet.tar.gz && ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
---> Running in 568bbfec1c71
[91m % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0[0m
[91m 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0[0m
[91m 12 159M 12 20.6M 0 0 17.8M 0 0:00:08 0:00:01 0:00:07 17.8M[0m
[91m 26 159M 26 42.7M 0 0 19.7M 0 0:00:08 0:00:02 0:00:06 19.7M[0m
[91m 40 159M 40 64.8M 0 0 20.5M 0 0:00:07 0:00:03 0:00:04 20.5M[0m
[91m 52 159M 52 84.4M 0 0 20.2M 0 0:00:07 0:00:04 0:00:03 20.2M[0m
[91m 67 159M 67 107M 0 0 20.9M 0 0:00:07 0:00:05 0:00:02 21.5M[0m
[91m 79 159M 79 127M 0 0 20.6M 0 0:00:07 0:00:06 0:00:01 21.3M[0m
[91m 90 159M 90 144M 0 0 20.1M 0 0:00:07 0:00:07 --:--:-- 20.3M[0m
[91m 100 159M 100 159M 0 0 19.8M 0 0:00:08 0:00:08 --:--:-- 19.3M
[0m
dotnet.tar.gz: OK
Removing intermediate container 568bbfec1c71
---> ec41a2979efa
Step 7/13 : RUN dotnet help
---> Running in 30a464b2a882
Welcome to .NET Core!
---------------------
Learn more about .NET Core: https://aka.ms/dotnet-docs
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs
Telemetry
---------
The .NET Core tools collect usage data in order to help us improve your experience. The data is anonymous and doesn't include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
Read more about .NET Core CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry
Configuring...
--------------
A command is running to populate your local package cache to improve restore speed and enable offline access. This command takes up to one minute to complete and only runs once.
Decompressing
.
.
.
.
.
.
.
.
.
.
34206 ms
Expanding
.
.
.
.
.
.
.
.
.
. 117599 ms
ASP.NET Core
------------
Successfully installed the ASP.NET Core HTTPS Development Certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only). For establishing trust on other platforms refer to the platform specific documentation.
For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
.NET Command Line Tools (2.1.804)
Usage: dotnet [runtime-options] [path-to-application] [arguments]
Execute a .NET Core application.
runtime-options:
--additionalprobingpath <path> Path containing probing policy and assemblies to probe for.
--additional-deps <path> Path to additional deps.json file.
--fx-version <version> Version of the installed Shared Framework to use to run the application.
--roll-forward-on-no-candidate-fx Roll forward on no candidate shared framework is enabled.
path-to-application:
The path to an application .dll file to execute.
Usage: dotnet [sdk-options] [command] [command-options] [arguments]
Execute a .NET Core SDK command.
sdk-options:
-d|--diagnostics Enable diagnostic output.
-h|--help Show command line help.
--info Display .NET Core information.
--list-runtimes Display the installed runtimes.
--list-sdks Display the installed SDKs.
--version Display .NET Core SDK version in use.
SDK commands:
add Add a package or reference to a .NET project.
build Build a .NET project.
build-server Interact with servers started by a build.
clean Clean build outputs of a .NET project.
help Show command line help.
list List project references of a .NET project.
migrate Migrate a project.json project to an MSBuild project.
msbuild Run Microsoft Build Engine (MSBuild) commands.
new Create a new .NET project or file.
nuget Provides additional NuGet commands.
pack Create a NuGet package.
publish Publish a .NET project for deployment.
remove Remove a package or reference from a .NET project.
restore Restore dependencies specified in a .NET project.
run Build and run a .NET project output.
sln Modify Visual Studio solution files.
store Store the specified assemblies in the runtime package store.
test Run unit tests using the test runner specified in a .NET project.
tool Install or manage tools that extend the .NET experience.
vstest Run Microsoft Test Engine (VSTest) commands.
Additional commands from bundled tools:
dev-certs Create and manage development certificates.
ef Entity Framework Core command-line tools.
fsi Start F# Interactive / execute F# scripts.
sql-cache SQL Server cache command-line tools.
user-secrets Manage development user secrets.
watch Start a file watcher that runs a command when files change.
Run 'dotnet [command] --help' for more information on a command.
Removing intermediate container 30a464b2a882
---> b612e03c4059
Step 8/13 : USER jenkins
---> Running in 9f8c234a9f3f
Removing intermediate container 9f8c234a9f3f
---> 42f00be02df1
Step 9/13 : RUN dotnet tool install --global dotnet-sonarscanner --version 4.9.0
---> Running in 883a2e55cda3
Welcome to .NET Core!
---------------------
Learn more about .NET Core: https://aka.ms/dotnet-docs
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs
Telemetry
---------
The .NET Core tools collect usage data in order to help us improve your experience. The data is anonymous and doesn't include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
Read more about .NET Core CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry
ASP.NET Core
------------
Successfully installed the ASP.NET Core HTTPS Development Certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only). For establishing trust on other platforms refer to the platform specific documentation.
For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
/usr/share/dotnet/sdk/2.1.804/NuGet.targets(123,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [/tmp/rtcuxyki.gid/restore.csproj]
/usr/share/dotnet/sdk/2.1.804/NuGet.targets(123,5): error : The SSL connection could not be established, see inner exception. [/tmp/rtcuxyki.gid/restore.csproj]
/usr/share/dotnet/sdk/2.1.804/NuGet.targets(123,5): error : Authentication failed, see inner exception. [/tmp/rtcuxyki.gid/restore.csproj]
/usr/share/dotnet/sdk/2.1.804/NuGet.targets(123,5): error : The type initializer for 'SslMethods' threw an exception. [/tmp/rtcuxyki.gid/restore.csproj]
/usr/share/dotnet/sdk/2.1.804/NuGet.targets(123,5): error : The type initializer for 'Ssl' threw an exception. [/tmp/rtcuxyki.gid/restore.csproj]
/usr/share/dotnet/sdk/2.1.804/NuGet.targets(123,5): error : The type initializer for 'SslInitializer' threw an exception. [/tmp/rtcuxyki.gid/restore.csproj]
/usr/share/dotnet/sdk/2.1.804/NuGet.targets(123,5): error : error:0E076071:configuration file routines:MODULE_RUN:unknown module name [/tmp/rtcuxyki.gid/restore.csproj]
[91mThe tool package could not be restored.
Tool 'dotnet-sonarscanner' failed to install. This failure may have been caused by:
* You are attempting to install a preview release and did not use the --version option to specify the version.
* A package by this name was found, but it was not a .NET Core tool.
* The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
* You mistyped the name of the tool.
[0m
Removing intermediate container 883a2e55cda3
The command '/bin/sh -c dotnet tool install --global dotnet-sonarscanner --version 4.9.0' returned a non-zero code: 1

0 个答案:

没有答案