'add hostname mappings using --add-host parameter not working for scratch image

Add hostname mappings using the --add-host parameter is not working for a scratch image.

I configure it as following:

extra_hosts:
  - "op.swish-cloud.com:10.170.0.2"

But the actual id of requests from the container is the external internet ip of op.swish-cloud.com rather than 10.170.0.2



Solution 1:[1]

In case anyone ends up here from a Google search, this is going to be expected behavior. You need to mount a file as /etc/hosts or at least make sure the file exists in order for --add-host to work in the scratch image.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 cardonator