From 53b2ced2983dd822347dee93f878e37217178040 Mon Sep 17 00:00:00 2001 From: Panboo Date: Thu, 5 Feb 2026 11:10:49 +0800 Subject: [PATCH] fix: add background execution to python http server example Add '&' to run python3 in background so users can execute the docker run command in the same terminal session. Add 'kill %1' to stop the HTTP server after the example. Fixes #5558 --- docs/reference/commandline/container_run.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/reference/commandline/container_run.md b/docs/reference/commandline/container_run.md index dcf4c52f41e2..bf3fdc14a35a 100644 --- a/docs/reference/commandline/container_run.md +++ b/docs/reference/commandline/container_run.md @@ -1292,12 +1292,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 +$ 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 hello from host! +$ kill %1 # Stop the HTTP server ``` The `--add-host` flag also accepts a `:` separator, for example: