简体   繁体   English

Azure容器实例Windows容器无法访问Internet?

[英]Azure Container Instances no internet access for Windows Container?

My Windows Container in Azure Container Instances does not seem to be able to access the internet. 我在Azure容器实例中的Windows容器似乎无法访问Internet。

在此处输入图片说明

What can I do to access the internet from my Windows Container? 如何从Windows容器访问Internet?

I had to execute this PowerShell command in the container during startup: 在启动期间,我必须在容器中执行以下PowerShell命令:

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

Then my container was able to successfully resolve DNS and access the internet. 然后,我的容器能够成功解析DNS并访问Internet。

Executing this script in a RUN did not work, so I had to somehow execute it together with my already required CMD. 在RUN中执行此脚本无效,因此我不得不以某种方式与已经需要的CMD一起执行它。 I ended up doing it like this and it works: 我最终这样做了,它的工作原理是:

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

Don't forget to escape \\ and " . 不要忘记\\"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM