【问题标题】:Azure Container Instances no internet access for Windows Container?Azure 容器实例无法访问 Windows 容器的 Internet?
【发布时间】:2019-07-19 17:20:17
【问题描述】:

Azure 容器实例中的我的 Windows 容器似乎无法访问 Internet。

如何从我的 Windows 容器访问互联网?

【问题讨论】:

    标签: azure azure-container-instances


    【解决方案1】:

    我必须在启动期间在容器中执行这个 PowerShell 命令:

    Set-DnsClientServerAddress -InterfaceIndex (Get-NetAdapter).IfIndex -ServerAddresses ('8.8.8.8')
    

    然后我的容器能够成功解析 DNS 并访问互联网。

    在 RUN 中执行此脚本不起作用,所以我不得不以某种方式将它与我已经需要的 CMD 一起执行。我最终这样做了,它可以工作:

    CMD ["powershell", "-Command", "\"Set-DnsClientServerAddress -InterfaceIndex (Get-NetAdapter).IfIndex -ServerAddresses ('8.8.8.8')\"; cd c:\\app; .\\my.exe ui"]
    

    别忘了转义\"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-26
      相关资源
      最近更新 更多