microsoft / DockerTools

Tools For Docker, including Visual Studio Provisioning and Publishing
Other
175 stars 26 forks source link

Can't publish to custom repository that doesn't have https #155

Open Misiu opened 5 years ago

Misiu commented 5 years ago

I have a custom repository that I want to deploy my docker image to. I've added my custom repository URL into Docker Settings: docker_insecure_repository I've created a simple ASP.NET Core 2.1 project in Visual Studio 15.8.9.

This is my Dockerfile:

FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80

FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY ["DockerTestLinux/DockerTestLinux.csproj", "DockerTestLinux/"]
RUN dotnet restore "DockerTestLinux/DockerTestLinux.csproj"
COPY . .
WORKDIR "/src/DockerTestLinux"
RUN dotnet build "DockerTestLinux.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "DockerTestLinux.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "DockerTestLinux.dll"]

this is my pubxml file:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>Custom</WebPublishMethod>
    <DockerPublish>true</DockerPublish>
    <RegistryUrl>http://172.18.3.83:5000</RegistryUrl>
    <UserName />
    <PublishImageTag>latest</PublishImageTag>
    <PublishProvider>ContainerRegistry</PublishProvider>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <ProjectGuid>e345236e-5fa6-476d-9079-47711a444f5d</ProjectGuid>
  </PropertyGroup>
</Project>

When I click on Publish I get this error: docker_publish_error

and here are the details from diagnostic log file:

2018-11-05 13:10:16
Microsoft.VisualStudio.Web.Azure.Publish.Docker.DockerCommandException: Running the docker.exe login command failed.

WARNING! Using --password via the CLI is insecure. Use --password-stdin.Error response from daemon: Get https://172.18.3.83/v2/: dial tcp 172.18.3.83:443: connect: connection refused
   at Microsoft.VisualStudio.Web.Azure.Publish.ContainerRegistryProfileVisual.ThrowDockerCommandError(String dockerCommand)
   at Microsoft.VisualStudio.Web.Azure.Publish.ContainerRegistryProfileVisual.<DockerLoginAsync>d__30.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Microsoft.VisualStudio.Web.Azure.Publish.ContainerRegistryProfileVisual.<PostPublishAsync>d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ApplicationCapabilities.Publish.ViewModel.ProfileSelectorViewModel.<RunPublishTaskAsync>d__127.MoveNext()
===================

As You can see during publish VS tries to access https://172.18.3.83:443, but I have insecure repository so it should use port 80 instead.

EDIT: I've managed to push my image using CLI:

docker tag dockertestlinux 172.18.3.83:5000/dockertestlinux
docker push 172.18.3.83:5000/dockertestlinux

but ideally I would like to be able to do the same from Visual Studio.

bwateratmsft commented 5 years ago

Hey @Misiu , this is related to this Developer Community issue, and should be fixed together with it.

Misiu commented 5 years ago

@bwateratmsft thank You for the link :)

Nonobis commented 4 years ago

Hello, I have same error on lastest community version 2019 (home) and i have tested at work with vs 2019 pro ..... => Version Visual Studio Pro 2019 (16.3.3) et Visual Studio Community 2019 (16.3.3).

Any solution ?

thx

Levvy055 commented 4 years ago

Hitting the same wall. For custom container registry should be option to publish with already logged account.

edobarnes commented 4 years ago

Same error.

Microsoft Visual Studio Enterprise 2019 Version 16.5.4

We are trying to publish to a Docker instance on a network VM.

KaFuzLuM commented 4 years ago

Same error, Trying to publish container to Harbor instance. It keeps appending "/V2/" to the URL: image VS 2019 16.4.3

jvanlangen commented 3 years ago

Any thoughts on this yet?

ghost commented 3 years ago

Same issue with me when I try to publish via Visual Studio 2019 to ACR. My Docker Desktop is of version - 2.5.0.1 and VS version is - 16.7.6

Getting below error:

Publish has encountered an error.
Running the docker.exe login command failed.

WARNING! Using --password via the CLI is insecure. Use --password-stdin.

A diagnostic log has been written to the following location:
"C:\Users\Admin\AppData\Local\Temp\tmp2719.tmp"

Full stack trace file: tmp4ED7.txt

jvanlangen commented 3 years ago

I've managed it by adding the my custom repository hostname/ip in the Settings of my local docker engine. Create a section called insecure-registries. Visual studio uses your local docker installation to publish an image to a remote repo. (learned the hard way)

This is an example of docker Settings => Docker Engine (on windows)

{
  "registry-mirrors": [],
  "insecure-registries": [
    "MyRepo:5000"
  ],
  "debug": true,
  "experimental": false
}
ghost commented 3 years ago

@jvanlangen Thanks but I am actually trying to publish to Azure Container Registry (ACR) in the cloud and not local repository. I have created a new issue on this link.

I however tried your way and added "myrepo.azurecr.io" but it did not work. If you have any suggestions for me, kindly let me know. Thank you.

swtrse commented 3 years ago

I've managed it by adding the my custom repository hostname/ip in the Settings of my local docker engine. Create a section called insecure-registries. Visual studio uses your local docker installation to publish an image to a remote repo. (learned the hard way)

This is an example of docker Settings => Docker Engine (on windows)

{
  "registry-mirrors": [],
  "insecure-registries": [
    "MyRepo:5000"
  ],
  "debug": true,
  "experimental": false
}

This was exactly my problem. Thanks.

LukasKubicek commented 10 months ago

Same error 5 years later... Probably best not to count on Microsoft..