From 6bcb137d2f2e9bf65e3f3c1bb2f7667f5308f2cd Mon Sep 17 00:00:00 2001 From: Jason Heiss Date: Wed, 9 Mar 2016 20:40:12 -0500 Subject: [PATCH] Allow --hostname with --net=host Docker creates a UTS namespace by default, even with --net=host, so it is reasonable to let the user set the hostname. Note that --hostname is forbidden if the user specifies --uts=host. Closes #12076 Signed-off-by: Jason Heiss --- docs/reference/run.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/reference/run.md b/docs/reference/run.md index 4be50a2d02..37ac49fb1b 100644 --- a/docs/reference/run.md +++ b/docs/reference/run.md @@ -237,15 +237,13 @@ $ docker run -it --rm --pid=host myhtop The UTS namespace is for setting the hostname and the domain that is visible to running processes in that namespace. By default, all containers, including those with `--net=host`, have their own UTS namespace. The `host` setting will -result in the container using the same UTS namespace as the host. +result in the container using the same UTS namespace as the host. Note that +`--hostname` is invalid in `host` UTS mode. You may wish to share the UTS namespace with the host if you would like the hostname of the container to change as the hostname of the host changes. A more advanced use case would be changing the host's hostname from a container. -> **Note**: `--uts="host"` gives the container full access to change the -> hostname of the host and is therefore considered insecure. - ## IPC settings (--ipc) --ipc="" : Set the IPC mode for the container, @@ -365,8 +363,11 @@ name, they must be linked. With the network set to `host` a container will share the host's network stack and all interfaces from the host will be available to the container. The container's hostname will match the hostname on the host -system. Note that `--add-host` `--hostname` `--dns` `--dns-search` -`--dns-opt` and `--mac-address` are invalid in `host` netmode. +system. Note that `--add-host` `--dns` `--dns-search` +`--dns-opt` and `--mac-address` are invalid in `host` netmode. Even in `host` +network mode a container has its own UTS namespace by default. As such +`--hostname` is allowed in `host` network mode and will only change the +hostname inside the container. Compared to the default `bridge` mode, the `host` mode gives *significantly* better networking performance since it uses the host's native networking stack