From 0638fe265aae9c00c4a2fa26204cbb282f491209 Mon Sep 17 00:00:00 2001 From: Nanook Date: Mon, 13 Apr 2026 19:10:20 +0000 Subject: [PATCH] docs: fix --add-host example to work in a single terminal session The current example uses python3 -m http.server which runs in the foreground, blocking the terminal and preventing the user from running the subsequent docker command. The example only works if the user opens a second terminal. Replace with nc (netcat) which can be backgrounded with & disown, allowing the entire example to run in a single terminal session. This also removes the dependency on Python being installed on the host. Fixes docker/cli#5558 Signed-off-by: Nanook --- docs/reference/commandline/container_run.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/docs/reference/commandline/container_run.md b/docs/reference/commandline/container_run.md index dcf4c52f41e2..0d84e61d8f58 100644 --- a/docs/reference/commandline/container_run.md +++ b/docs/reference/commandline/container_run.md @@ -1291,12 +1291,8 @@ example runs an HTTP server that serves a file from host to container over the `host.docker.internal` hostname, which resolves to the host's internal IP. ```console -$ echo "hello from host!" > ./hello -$ python3 -m http.server 8000 -Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ... -$ docker run \ - --add-host host.docker.internal=host-gateway \ - curlimages/curl -s host.docker.internal:8000/hello +$ printf 'HTTP/1.1 200 OK\r\n\r\nhello from host!\n' | nc -l 8000 & disown +$ docker run --add-host host.docker.internal=host-gateway curlimages/curl -s host.docker.internal:8000 hello from host! ```