Add a networking example

This commit is contained in:
Usha Mandya 2020-07-31 14:51:17 +01:00
parent 0eaa4ae3cc
commit 31200920d7
2 changed files with 42 additions and 12 deletions

View File

@ -68,13 +68,28 @@ There are two scenarios that the above limitations affect:
#### I want to connect from a container to a service on the host
The host has a changing IP address (or none if you have no network access). From
18.03 onwards our recommendation is to connect to the special DNS name
`host.docker.internal`, which resolves to the internal IP address used by the
host.
This is for development purpose and will not work in a production environment outside of Docker Desktop for Mac.
The host has a changing IP address (or none if you have no network access). We recommend that you connect to the special DNS name
`host.docker.internal` which resolves to the internal IP address used by the
host. This is for development purpose and will not work in a production environment outside of Docker Desktop for Mac.
The gateway is also reachable as `gateway.docker.internal`.
You can also reach the gateway using `gateway.docker.internal`.
If you have installed Python on your machine, use the following instructions as an example to connect from a container to a service on the host:
1. Run the following command to start a simple HTTP server on port 8000.
`python -m http.server 8000`
If you have installed Python 2.x, run `python -m SimpleHTTPServer 8000`.
2. Now, run a container, install `curl`, and try to connect to the host using the following commands:
```console
$ docker run --rm -it alpine sh
# apk add curl
# curl http://host.docker.internal:8000
# exit
```
#### I want to connect to a container from the Mac

View File

@ -68,13 +68,28 @@ There are two scenarios that the above limitations affect:
#### I want to connect from a container to a service on the host
The host has a changing IP address (or none if you have no network access). From
18.03 onwards our recommendation is to connect to the special DNS name
`host.docker.internal`, which resolves to the internal IP address used by the
host.
This is for development purpose and will not work in a production environment outside of Docker Desktop for Windows.
The host has a changing IP address (or none if you have no network access). We recommend that you connect to the special DNS name
`host.docker.internal` which resolves to the internal IP address used by the
host. This is for development purpose and will not work in a production environment outside of Docker Desktop for Windows.
The gateway is also reachable as `gateway.docker.internal`.
You can also reach the gateway using `gateway.docker.internal`.
If you have installed Python on your machine, use the following instructions as an example to connect from a container to a service on the host:
1. Run the following command to start a simple HTTP server on port 8000.
`python -m http.server 8000`
If you have installed Python 2.x, run `python -m SimpleHTTPServer 8000`.
2. Now, run a container, install `curl`, and try to connect to the host using the following commands:
```console
$ docker run --rm -it alpine sh
# apk add curl
# curl http://host.docker.internal:8000
# exit
```
#### I want to connect to a container from Windows