2

Since the extra_hosts: option in my docker-compose.yml is not working, I'm trying to manipulate the etc/hosts file in my running windows container.

cd C:\Windows\System32\drivers\etc
echo 192.168.x.x testdomain > hosts

The console returns:

Access is denied.

How can I manipulate the hosts file, during startup/runtime/build? Maybe the extra_hosts: is not working because of "access denied"?

Setup:

  • Windows 10, 2004
  • Docker version: 19.03.12
  • image: mcr.microsoft.com/windows/nanoserver:1903
flavio.donze
  • 7,432
  • 9
  • 58
  • 91
  • 1
    [How can I add DNS entries to hosts file of a Windows Container?](https://stackoverflow.com/q/63880160/3110834) – Reza Aghaei Dec 28 '20 at 20:14
  • Maybe try "become: yes" below your service statement in the compose file. "services: container: become: yes" – Lucas Raza Apr 02 '21 at 18:19

0 Answers0