Merge pull request #11202 from usha-mandya/11172-patch

Add a networking example
This commit is contained in:
Usha Mandya 2020-07-31 15:23:07 +01:00 committed by GitHub
commit d409cd73bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 #### 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 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
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.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.
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 #### 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 #### 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 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
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.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.
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 #### I want to connect to a container from Windows