microsoft / DockerTools

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

Error "CTC1014" Docker command failed with exit code 1. The command 'cmd /S /C dotnet restore "AssignmentDeltaXAPI/AssignmentDeltaXAPI.csproj"' returned a non-zero code: 1 #350

Closed ks1990cn closed 1 year ago

ks1990cn commented 1 year ago

Hi All,

I've one repo : https://github.com/ks1990cn/Demo_API_For_IMDB In this repo, my Docker File is at https://github.com/ks1990cn/Demo_API_For_IMDB/tree/main/API/AssignmentDeltaXAPI

I tried to create Docker image using docker support tool for windows by referring to https://www.youtube.com/watch?v=k2sskhYEPkI

I just right clicked on my API -> Docker support -> For Windows then tried to build the image.

If I select to run & debug using Docker its running fine but getting error when I tried to build this image.

I also referred to #247 (https://github.com/microsoft/DockerTools/issues/247) but didn't worked for me.

Please let me know if anyone need further information and kindly help me on this.

Thanks!

NCarlsonMSFT commented 1 year ago

@ks1990cn the logs from the docker build hopefully contain an error message from the NuGet restore. I downloaded your repro locally and it built for me, so this does seem like it may be a networking issue. Bonus info request. What output do you get if you run docker run -it mcr.microsoft.com/dotnet/sdk:5.0 curl https://api.nuget.org/v3/index.json.

ks1990cn commented 1 year ago

@NCarlsonMSFT here are logs:

C:\Users\tanmays>docker pull mcr.microsoft.com/dotnet/sdk:5.0 5.0: Pulling from dotnet/sdk Digest: sha256:3ff465d940de3e2c727794d92fd7bb649c498d4abd91bc9213ea7831ebf01f1e Status: Image is up to date for mcr.microsoft.com/dotnet/sdk:5.0 mcr.microsoft.com/dotnet/sdk:5.0

C:\Users\tanmays>docker run -it mcr.microsoft.com/dotnet/sdk:5.0 curl https://api.nuget.org/v3/index.json curl: (6) Could not resolve host: api.nuget.org

How to resolve this nuget issue cause I'm unable to publish it to docker hub too.

NCarlsonMSFT commented 1 year ago

@ks1990cn the error you're getting from curl suggests that your container is having DNS issues. Is your host using a proxy? If so take a look at https://docs.docker.com/network/proxy/ to make sure your container is using it too. Are you able to use curl to connect to other sites, for instance: docker run -it mcr.microsoft.com/dotnet/sdk:5.0 curl http://www.microsoft.com/?

ks1990cn commented 1 year ago

Yeah seems like issue with my path... something is wrong with my docker file should be in root directory!

I'll try again.. we can close this for now... but if required I'll text you here!

Thanks for great support.

NCarlsonMSFT commented 1 year ago

@ks1990cn FYI: The Dockerfile not being at the root is the expected behavior of the Dockerfile scaffolding in VS. To support building in a container with project to project references we set the build context to the solution folder but still place the dockerfile in the project folder.

Regardless of that, your inability to connect using curl when directly running the image still points to a networking issue that is broader than the individual container / Dockerfile used in this project

ks1990cn commented 1 year ago

Yes I tried creating any other application, it worked for it... but still an issue for this

I need to explore about host proxy.