azure-cli: az login: Failed to establish a new connection: [Errno -2] Name does not resolve

This is autogenerated. Please review and update as needed.

Describe the bug

When logging in with azure cli inside of mcr.microsoft.com/azure-cli:2.32.0 container I get an error (See below), The same login command works if I login outside of the container on my host.

Command Name az login

Errors:

<urllib3.connection.HTTPSConnection object at 0x7f3ed60e6490>: Failed to establish a new connection: [Errno -2] Name does not resolve

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • Put any pre-requisite steps here…
  • az login --service-principal -u {} -p {} --tenant {}

Expected Behavior

Should have successfully signed in.

Environment Summary

Linux-5.4.0-99-generic-x86_64-with, Alpine Linux v3.14
Python 3.9.6
Installer: DOCKER

azure-cli 2.32.0 *

Additional Context

Running inside a mcr.microsoft.com/azure-cli:2.32.0 container

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 17 (5 by maintainers)

Most upvoted comments

The issue seems to be with URL from inside docker only: https://management.azure.com/tenants?api-version=2019-11-01

Steps to reproduce: $ docker run -it --rm mcr.microsoft.com/azure-cli:latest bash-5.1# curl https://management.azure.com/tenants?api-version=2019-11-01 curl: (6) Could not resolve host: management.azure.com

Same command from outside docker works fine: $ curl https://management.azure.com/tenants?api-version=2019-11-01 {“error”:{“code”:“AuthenticationFailed”,“message”:“Authentication failed. The ‘Authorization’ header is missing.”}}

DNS resolution fails, but only from inside docker (outside docker works fine):

bash-5.1# cat /etc/resolv.conf
nameserver 10.0.2.3
nameserver 172.30.240.1
bash-5.1# nslookup management.azure.com 172.30.240.1
Server:         172.30.240.1
Address:        172.30.240.1:53

Non-authoritative answer:
*** Can't find management.azure.com: Parse error

Non-authoritative answer:
*** Can't find management.azure.com: Parse error
bash-5.1# nslookup management.azure.com 10.0.2.3
Server:         10.0.2.3
Address:        10.0.2.3:53

Non-authoritative answer:
*** Can't find management.azure.com: Parse error

Non-authoritative answer:
*** Can't find management.azure.com: Parse error