How can I add DNS entries to hosts file of a Windows Container?

后端 未结 1 545
误落风尘
误落风尘 2021-01-26 04:44

I have a website in IIS of my host machine which is accessible by http://mysite.local address. I also have a windows container running on this host and I\'m trying to connect to

1条回答
  •  情歌与酒
    2021-01-26 05:13

    You can get the command shell of the container as administrator and run the command:

    docker exec --user "NT AUTHORITY\SYSTEM" -it yourcontainername cmd
    

    Then you can add a proper record to hosts file of the container:

    echo X.X.X.X mysite.local >> c:\windows\system32\drivers\etc\hosts
    

    To make sure you are using proper value instead of X.X.X.X, open hosts file of your host machine, and you will see a DNS entry like X.X.X.X host.docker.internal. This is the IP of host in container's point of view. Use that IP in above command to add thee correct DNS entry to hosts file of the container. To test the result, you can see the content of the file using type c:\windows\system32\drivers\etc\hosts and get contents from that website using curl mysite.local.

    0 讨论(0)
提交回复
热议问题