Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add-host or extra_host not working for windows container

  • Environment : Docker for Windows
  • Container : Windows Container

In docker run command , there is --add-host option. This is not working for Windows container.

Same way there is a configuration option in a compose file , extra_host. This is also not working for windows container.

Is there any specific reason , this is not working for windows container ?

like image 621
dotnetstep Avatar asked Oct 30 '25 14:10

dotnetstep


1 Answers

See docker source tree: this & this:

func (s *DockerSuite) TestRunAddHost(c *check.C) {
// Not applicable on Windows as it does not support --add-host

func (s *DockerSuite) TestRunCreateVolumeEtc(c *check.C) {
// While Windows supports volumes, it does not support --add-host hence
// this test is not applicable on Windows.

So, I guess this is the current limit for docker for windows although I don't know why they did not support it.

And, you are not alone here, see this discussion, and folks' suggestion is put next to Dockerfile as workaround:

RUN $file = $Env:windir+'\System32\drivers\etc\hosts'; `
'10.0.0.1 some.host.com' | Add-Content -PassThru $file;
like image 103
atline Avatar answered Nov 03 '25 03:11

atline



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!