docs: document special host-gateway value for add-host

Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
This commit is contained in:
David Karlsson
2023-07-03 16:34:55 +02:00
parent dc2eb3bf7c
commit 299925f4c3
3 changed files with 47 additions and 14 deletions

View File

@ -458,7 +458,17 @@ You can add other hosts into a container's `/etc/hosts` file by using one or
more `--add-host` flags. This example adds a static address for a host named
`docker`:
$ docker build --add-host=docker:10.180.0.1 .
```console
$ docker build --add-host docker:10.180.0.1 .
```
If you need your build to connect to services running on the host, you can use
the special `host-gateway` value for `--add-host`. In the following example,
build containers resolve `host.docker.internal` to the host's gateway IP.
```console
$ docker build --add-host host.docker.internal:host-gateway .
```
### <a name="target"></a> Specifying target build stage (--target)