From f2f7fee21e8a46d1b797075c6dfdb017dc7b70fd Mon Sep 17 00:00:00 2001 From: Indra Prasetya <11029197+indraoverflow@users.noreply.github.com> Date: Thu, 12 Nov 2026 22:39:19 +0000 Subject: [PATCH] docs: fix --add-host example to run HTTP server in background Fixes #5558 The example for the --add-host flag with host-gateway ran the Python HTTP server in the foreground, preventing the user from running the docker command in the same terminal. This change runs the server in the background and kills it after the curl command completes. Signed-off-by: Indra Prasetya <11029197+indraoverflow@users.noreply.github.com> --- docs/reference/commandline/container_run.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/reference/commandline/container_run.md b/docs/reference/commandline/container_run.md index 79d04c9c0aa4..07a5427995dd 100644 --- a/docs/reference/commandline/container_run.md +++ b/docs/reference/commandline/container_run.md @@ -1293,12 +1293,13 @@ example runs an HTTP server that serves a file from host to container over the ```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/) ... +$ python3 -m http.server 8000 & +[1] 12345 $ docker run \ --add-host host.docker.internal=host-gateway \ curlimages/curl -s host.docker.internal:8000/hello hello from host! +$ kill %1 ``` The `--add-host` flag also accepts a `:` separator, for example: