Avinash Singh
Avinash Singh

Reputation: 2785

The DOCKER_REGISTRY variable is not set. Defaulting to a blank string

I have created a new DotNetCore 2.0 web project in VisualStudio 2017. I have docker running in machine with Docker Server Host configured for Windows.

While running solution i'm getting below error,

'The DOCKER_REGISTRY variable is not set. Defaulting to a blank string.'

Building myfirstdotnetcore Service 'myfirstdotnetcore' failed to build:

Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).

Upvotes: 9

Views: 17051

Answers (9)

Fakhar Ahmad Rasul
Fakhar Ahmad Rasul

Reputation: 1691

I tried everything mentioned above but nothing worked. The issue for me was simply the fact that I did not have an environment variable named DOCKER_REGISTRY, as it clearly states in the error, so I created a system environment variable named DOCKER_REGISTRY and gave the path C: to it. This answer helped me. Remember to restart your system after creating the variable.

Upvotes: 1

MaciejLisCK
MaciejLisCK

Reputation: 3974

  1. Run Visual Studio as Administrator
  2. Right click on Docker tray icon -> Restart

Upvotes: 0

Sameer Awate
Sameer Awate

Reputation: 99

In Docker Settings -> Network, I switched the DNS Server setting to "Fixed" as below and it worked for me! Hope that helps

enter image description here

Upvotes: 1

saurav Sinha
saurav Sinha

Reputation: 448

Just clean the project solution explorer and rebuild the solution.

Upvotes: 0

Steve Land
Steve Land

Reputation: 4862

I found these related issues on github:

TLDR; This error is misleading, and can mask several internal docker errors which Visual Studio currently swallows (these should be visible in your build output) - this is expected to be fixed in Visual Studio 2017 15.8 but as of 15.8.2 this is still a problem and the bug is still open, so I assume its still on the way.

Until then, the general consensus seems to be that the following step combination should workaround most of the underlying issues. NB! these might need to be repeated after machine restarts.

  • Run Visual Studio as Administrator
  • Ensure you are logged in to Docker - e.g. run docker login
  • Restart Docker for windows (right click in system tray and select restart)

I'm not certain if the order of the above might be important.

Upvotes: 2

Donal
Donal

Reputation: 32713

I needed to set docker registry Environment Variable. Path needs to be lowercase for some reason.

[Environment]::SetEnvironmentVariable("DOCKER_REGISTRY", "d:\docker\registry\", "Machine")

Upvotes: 3

Tiago Ávila
Tiago Ávila

Reputation: 2867

I did almost like @David Silwal said.

I ran Visual Studio as Admin.

I was already logged-in on my docker hub account, but even like that, it wasn't working.

So I logged-out and logged-in again. Then, it worked!

Upvotes: 0

David Silwal
David Silwal

Reputation: 531

I had this issue and has resolved after taken below steps.

Run Visual Studio as Administrator

Your running Docker host should logged-in to your DockerHub account.

This is very important The main reason for this issue is Visual Studio couldn't download nano server image from docker hub. So always make sure that you logged in to your dockerhub account from running host

Upvotes: 14

Malek A
Malek A

Reputation: 21

Do you have the detailed error message? I had a similar problem, turned out that virtualization wasn't enabled on my machine.

run 'systeminfo' in power shell, and make sure that hyper-v is enabled

Upvotes: 0

Related Questions