Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default Uri is wrong when dotnet publish docker image to insecure registry #43618

Closed
dameng324 opened this issue Sep 23, 2024 · 2 comments · Fixed by #44050
Closed

Default Uri is wrong when dotnet publish docker image to insecure registry #43618

dameng324 opened this issue Sep 23, 2024 · 2 comments · Fixed by #44050
Labels
Area-Workloads untriaged Request triage from a team member

Comments

@dameng324
Copy link
Contributor

Describe the bug

When publish dotnet app to an insecure docker registry, It throw an exception. Seems the port is wrong.

registry uri should be: http://dockerhub.shengguanda.com:80
but the exception say it request: http://dockerhub.shengguanda.com:443

To Reproduce

  1. create a web/blazor app
  2. add a insecure registry in csproj
    <PropertyGroup>
        <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
        <ContainerRegistry>dockerhub.shengguanda.com</ContainerRegistry>
        <ContainerRepository>sgd/test-app</ContainerRepository>
        <ContainerImageTags>$(Version)</ContainerImageTags>
        <ContainerUser>root</ContainerUser>
    </PropertyGroup>
  1. execute : dotnet publish -p:PublishProfile=DefaultContainer --os linux --arch x64 -c Release -p:Version=0.0.0.1
  2. then you will see the error.
  3. I have tried 8.0.401 and 9.0.100-rc.1, same result.

Exceptions (if any)

BlazorApp1 failed with 1 error(s) (12.0s) → bin\Release\net8.0\linux-x64\publish\
    C:\Program Files\dotnet\sdk\9.0.100-rc.1.24452.12\Containers\build\Microsoft.NET.Build.Containers.targets(241,5): error :
      Containerize: error CONTAINER004: CONTAINER1014: Manifest pull failed.
      URI: http://dockerhub.shengguanda.com:443/v2/sgd/test-app/blobs/sha256:fe7649cc1e2bc620e86b0a0fce8c281f1c6283e9e4498f4935fd916737c67c97
      HTTP status code: BadGateway
         at Microsoft.NET.Build.Containers.DefaultBlobOperations.LogAndThrowContainerHttpException[T](HttpResponseMessage response, CancellationToken cancellationToken) in /_/src/Containers/Microsoft.NET.Build.Containers/Re      gistry/DefaultBlobOperations.cs:line 79
         at Microsoft.NET.Build.Containers.DefaultBlobOperations.ExistsAsync(String repositoryName, String digest, CancellationToken cancellationToken) in /_/src/Containers/Microsoft.NET.Build.Containers/Registry/DefaultBlo      bOperations.cs:line 40
         at Microsoft.NET.Build.Containers.Registry.<>c__DisplayClass43_0.<<PushAsync>b__0>d.MoveNext() in /_/src/Containers/Microsoft.NET.Build.Containers/Registry/Registry.cs:line 444
      --- End of stack trace from previous location ---
         at Microsoft.NET.Build.Containers.Registry.PushAsync(BuiltImage builtImage, SourceImageReference source, DestinationImageReference destination, Boolean pushTags, CancellationToken cancellationToken) in /_/src/Conta      iners/Microsoft.NET.Build.Containers/Registry/Registry.cs:line 472
         at Microsoft.NET.Build.Containers.Tasks.CreateNewImage.PushToRemoteRegistryAsync(BuiltImage builtImage, SourceImageReference sourceImageReference, DestinationImageReference destinationImageReference, Telemetry tele      metry, CancellationToken cancellationToken) in /_/src/Containers/Microsoft.NET.Build.Containers/Tasks/CreateNewImage.cs:line 246

Further technical details

  • Include the output of dotnet --info
.NET SDK:
 Version:           9.0.100-rc.1.24452.12
 Commit:            81a714c6d3
 Workload version:  9.0.100-manifests.7c9f0ee8
 MSBuild version:   17.12.0-preview-24422-09+d17ec720d

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22621
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\9.0.100-rc.1.24452.12\

.NET workloads installed:
Configured to use loose manifests when installing new manifests.
 [maccatalyst]
   Installation Source: VS 17.11.35303.130, VS 17.12.35209.166
   Manifest Version:    17.5.9231-net9-p7/9.0.100-preview.7
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100-preview.7\microsoft.net.sdk.maccatalyst\17.5.9231-net9-p7\WorkloadManifest.json
   Install Type:              Msi

 [maui-windows]
   Installation Source: VS 17.11.35303.130, VS 17.12.35209.166
   Manifest Version:    9.0.0-preview.7.24407.4/9.0.100-preview.7
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100-preview.7\microsoft.net.sdk.maui\9.0.0-preview.7.24407.4\WorkloadManifest.json
   Install Type:              Msi

 [aspire]
   Installation Source: VS 17.11.35303.130
   Manifest Version:    8.1.0/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.1.0\WorkloadManifest.json
   Install Type:        FileBased

 [android]
   Installation Source: VS 17.11.35303.130, VS 17.12.35209.166
   Manifest Version:    35.0.0-preview.7.41/9.0.100-preview.7
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100-preview.7\microsoft.net.sdk.android\35.0.0-preview.7.41\WorkloadManifest.json
   Install Type:              Msi

 [ios]
   Installation Source: VS 17.11.35303.130, VS 17.12.35209.166
   Manifest Version:    17.5.9231-net9-p7/9.0.100-preview.7
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100-preview.7\microsoft.net.sdk.ios\17.5.9231-net9-p7\WorkloadManifest.json
   Install Type:              Msi


Host:
  Version:      9.0.0-rc.1.24431.7
  Architecture: x64
  Commit:       static

.NET SDKs installed:
  6.0.133 [C:\Program Files\dotnet\sdk]
  7.0.317 [C:\Program Files\dotnet\sdk]
  8.0.203 [C:\Program Files\dotnet\sdk]
  8.0.206 [C:\Program Files\dotnet\sdk]
  8.0.400 [C:\Program Files\dotnet\sdk]
  8.0.401 [C:\Program Files\dotnet\sdk]
  9.0.100-preview.7.24407.12 [C:\Program Files\dotnet\sdk]
  9.0.100-rc.1.24452.12 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.33 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.0-preview.7.24406.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.0-rc.1.24452.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.33 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.0-preview.7.24405.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.0-rc.1.24431.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.33 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.0-preview.7.24405.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.0-rc.1.24452.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and its version
    Rider 2024.2.5
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Workloads untriaged Request triage from a team member labels Sep 23, 2024
@dameng324 dameng324 changed the title Default Uri is wrong when dotnet publish Default Uri is wrong when dotnet publish docker image to insecure registry Sep 23, 2024
@baronfel
Copy link
Member

baronfel commented Sep 23, 2024

Ok, let me make sure I understand -

If a user has a registry configured like this in Docker config:

  "insecure-registries": [
    "dockerhub.shengguanda.com"
  ],

Today we will try to communicate to that registry on https (on port 443 if a port was not set, otherwise the explicitly-set port) inside the SDK container tools. If that fails (either because the registry isn't bound to HTTPS or for some other reason unrelated to allowing an insecure registry), then a piece of our middleware will try to communicate to that registry via the http protocol, but still on port 443. This is the specific error that you encountered and would like to fix? It seems reasonable to do so, but I would see if instead of hardcoding a port-80 on the http redirect we could simply un-set the port (if not explicit port was set by the user on the registry configuration).

@tmds
Copy link
Member

tmds commented Oct 2, 2024

Until this is fixed, I assume you may work around it by explicitly including the port number in the registry name: dockerhub.shengguanda.com:80.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Workloads untriaged Request triage from a team member
Projects
None yet
3 participants