Skip to content

Commit d2beba0

Browse files
PCPC
authored andcommitted
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
1 parent 769e75a commit d2beba0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

docs/reference/commandline/container_run.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1292,12 +1292,13 @@ example runs an HTTP server that serves a file from host to container over the
12921292

12931293
```console
12941294
$ echo "hello from host!" > ./hello
1295-
$ python3 -m http.server 8000
1295+
$ python3 -m http.server 8000 &
12961296
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
12971297
$ docker run \
12981298
--add-host host.docker.internal=host-gateway \
12991299
curlimages/curl -s host.docker.internal:8000/hello
13001300
hello from host!
1301+
$ kill %1 # Stop the HTTP server
13011302
```
13021303

13031304
The `--add-host` flag also accepts a `:` separator, for example:

0 commit comments

Comments
 (0)