Unlike the entries in `/etc/hosts`, environment-variables for linked
containers are not automatically updated if the linked container is
restarted.
This adds a note to the documentation in;
https://docs.docker.com/userguide/dockerlinks/#environment-variables
and
https://docs.docker.com/reference/run/#env-environment-variables
To make users aware that this is the case and recommends them to use
the `/etc/hosts` entries in stead.
I added this change because users were expecting environment variables
to be updated automatically as well (https://github.com/docker/docker/issues/10164).
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -647,6 +647,12 @@ mechanism to communicate with a linked container by its alias: |
| 647 | 647 |
If you restart the source container (`servicename` in this case), the recipient |
| 648 | 648 |
container's `/etc/hosts` entry will be automatically updated. |
| 649 | 649 |
|
| 650 |
+> **Note**: |
|
| 651 |
+> Unlike host entries in the `/ets/hosts` file, IP addresses stored in the |
|
| 652 |
+> environment variables are not automatically updated if the source container is |
|
| 653 |
+> restarted. We recommend using the host entries in `/etc/hosts` to resolve the |
|
| 654 |
+> IP address of linked containers. |
|
| 655 |
+ |
|
| 650 | 656 |
## VOLUME (shared filesystems) |
| 651 | 657 |
|
| 652 | 658 |
-v=[]: Create a bind mount with: [host-dir]:[container-dir]:[rw|ro]. |
| ... | ... |
@@ -232,6 +232,12 @@ command to list the specified container's environment variables. |
| 232 | 232 |
> container. Similarly, some daemons (such as `sshd`) |
| 233 | 233 |
> will scrub them when spawning shells for connection. |
| 234 | 234 |
|
| 235 |
+> **Note**: |
|
| 236 |
+> Unlike host entries in the [`/ets/hosts` file](#updating-the-etchosts-file), |
|
| 237 |
+> IP addresses stored in the environment variables are not automatically updated |
|
| 238 |
+> if the source container is restarted. We recommend using the host entries in |
|
| 239 |
+> `/etc/hosts` to resolve the IP address of linked containers. |
|
| 240 |
+ |
|
| 235 | 241 |
You can see that Docker has created a series of environment variables with |
| 236 | 242 |
useful information about the source `db` container. Each variable is prefixed with |
| 237 | 243 |
`DB_`, which is populated from the `alias` you specified above. If the `alias` |